-
Notifications
You must be signed in to change notification settings - Fork 5
Add support for CI_JOB_TOKEN #27
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
Conversation
|
Hey @christheyankee, thanks for the PR. Overall I think this looks good, however we should only store 1 token of any type in backwards-compatible: private_token: 'o_bla98df'or modern: token: 'o_bla98df'
token_type: 'private'We would support loading the old format, but only save the modern format. If there are multiple tokens in the configuration, we don't know which token to use, and trying to use both tokens would create even more unpredictable behavior than already provided by the inconsistent permissions available via |
This behavior would actually be preserved since that would store a user token and |
python-gitlab does do that currently, but it's just a hack they must implement because they pull tokens from myriad sources. Their order of precedence ensures there aren't errors from the GitLab request, but it doesn't make any claim that the correct token is used.
|
|
ping @haboustak since you might not have seen f33b2b8 |
|
Hey @christheyankee, sorry for the delay in getting back to you - I've been traveling. When I get a chance over the next few days I'll pull down your version and use some of my existing projects to test and ensure the conversions work as expected. Should be good to go though. |
|
I finally managed to get around to trying this out over the weekend, sorry for taking so long. The configuration and backward-compatibility changes all worked. Unfortunately, I couldn't get When testing According to the CI_JOB_TOKEN docs a job token cannot be used to access the That should fix I performed my testing so far using GitLab CE, although I don't think EE would change the results. |
The CI_JOB_TOKEN cannot be used to access the projects API endpoint. Using a shallow project object allows us to access the ProjectJobsManager without making an API request.
The job token doesn't provide access to the API endpoints required to perform the update command. If you try it anyway, GitLab returns a 404 status code when accessing a project via the API using a job token. Work around this by checking the type of token during update and print a reasonable error message.
Fix token availability typo
ClickExceptions are handled by click and result in an error message
without a stack trace. This commit also provides a config-specific
Exception base class to provide additional context as to the source of
configuration errors.
Example:
Error: config.token_type: A job token cannot be used to update artifacts
Handle the case where config has both the old and new token settings. Also improve error reporting when config is missing (entirely, or any required element).
|
Thanks @christheyankee! |
Closes #26 -- Adds support for:
and maintains legacy support for: