New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Gitlab's CI_JOB_TOKEN #2743
Comments
cc/ @mavogel wdyt? |
also, related to #2738 ? |
Okay so actually I tried and there's only a last piece missing here... So for Gitlab, |
I would say to wait then... |
I tried to build and run the v1.3 on gitlab with |
would #2993 help? |
Hey! Thanks for the update, I think it's going in the right direction, but it's still not working :/ This is mostly on Gitlab's end, since their Release Link API is still not available via thei CI_JOB_TOKEN. I built an example repo, with the failed pipeline you can check here: https://gitlab.com/ngotchac/goreleaser-tester/-/jobs/2247096351 The issue is this one: https://gitlab.com/gitlab-org/gitlab/-/issues/250819 |
I think I rather wait for gitlab to fix on their end... |
Looks like this issue was fixed and released with 15.1 yesterday. |
nice, should we reopen and merge #2993 then? |
I wont be on 15.1 for a few more weeks but happy to test once I get there. |
amazing @arusso , thanks! |
Selfishly interested in this one, so I went ahead and gave it a test against gitlab.com (currently running >v15.1) and it works! Here's the project I tested with: https://gitlab.com/drewstinnett/goreleaser-ci-test And the subsequent successful GitLab run: https://gitlab.com/drewstinnett/goreleaser-ci-test/-/jobs/2697620483 I'm happy either way, but would you consider auto-detecting if the CI_JOB_TOKEN is in use, instead of requiring an additional config parameter? I was thinking something like: if token == os.Getenv("CI_JOB_TOKEN") { instead of if ctx.Config.GitLabURLs.UseJobToken { This is what I have in my gitlab_urls:
use_package_registry: true
use_job_token: true Happy to submit a PR or whatever, also happy to just use the way you already have it. Thanks as always for your awesome work |
isn't it always set in gitlab ci? (honest question, I don't really know) |
Yup! It's an automatic env var in all GitLab CI runs, so should be pretty safe I think. It's really cool to not have to have the long lived token shoved somewhere, so hoping this is a good long term thing |
so, the reason for that config is that this pr would not work on older gitlab versions, so probably we shouldn't auto use it if its always set - including old gitlab versions... |
I gotcha, that's a good point, thanks @caarlos0! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is your feature request related to a problem? Please describe.
So far, to push a release to Gitlab, one needs to setup a new API token, and configure the pipelines with it. However, there is already a job token available, via the
CI_JOB_TOKEN
env-var. It could be used to create a new release, but needs a special header to be set.Right now, goreleaser uses
gitlab.NewClient
, which registers aPrivateToken
which sets thePRIVATE-TOKEN
header value.What should be possible, is to call
NewJobClient
instead if theCI_JOB_TOKEN
is present (or via an option I guess), which would mostly remove the need to manage an API token.The text was updated successfully, but these errors were encountered: