Gitlab-plugin: Cannot add a "GitLab API Token" as a credential

Created on 10 Aug 2016  路  19Comments  路  Source: jenkinsci/gitlab-plugin

Context

  • Gitlab plugin version: 1.3.0
  • Gitlab version: 8.10.4
  • Jenkins version: 2.7.2

    Problem description

When I attempt to add a "GitLab API Token" as a credential under the "Git" section of Source Code Management when configuring a job, after the "Jenkins Credentials Provider: Jenkins" modal closes, I do not see the credential added to the credential dropdown box. Other credential types work fine in terms of populating this dropdown box.

GitLab credentials are added fine under the global Jenkins settings page (/configure), but these are not available in the job configuration git credential dropdown (this could work as a workaround for the first problem if they did).

doc improvement

Most helpful comment

If you want to use an api token to clone the repository, here's how:

  1. Create api token with api scope
  2. Create username/password credential in jenkins. Your gitlab username (the account the token is for) is the username and the token is the PW
  3. Make sure to use the https address, not ssh
  4. Use the token credential you created earlier in the git configuration

All 19 comments

After writing this issue, I was able to resolve the issue by selecting "- none -" for "Credentials" under Git in Source Code Management (even though this causes an immediate "Failed to connect to repository" validation error). This might still qualify as an issue or at least for an update to the README as it was a bit confusing to figure out.

OK, I think I understand the issue now. We're using two sets of credentials: "GitLab API token" for access to GitLab Webhooks and a separate one for cloning the git repo during builds. Leaving this issue open in case the maintainers want to provide further clarification in case this is not self-evident to other dumbdumbs like me :)

@coder-hugo @omehegan This definitely feels like a bug. What do you think?

Yep, that describes the issue I'm having. Thanks for getting back! Closing this issue because it is a duplicate.

Looks like I'm getting this issue still on 1.3.1 - any workarounds?

@samskiter Do you have installed the plain-credentials plugin in your Jenkins if not could you please install it and try it again although the absence of this plugin shouldn't cause any trouble with the latest version of the plugin.

@coder-hugo That seemed to fix it yes, thanks!

Actually JENKINS-36863 refers to the credentials dropdown for the global gitlab configuration in jenkins settings which is working fine.

This ticket refers to the credentials dropdown for the git settings in job configuration and it doesn't seem to be fixed even after updating every single component or settings up a new Jenkins. GitLab API Token credentials don't appear there.

@4311021x You can't use the GitLab API token for cloning the repository. For this you have to use either a SSH key or a Username/Password combination. Furthermore this dropdown is part of the git-plugin not the gitlab-plugin. So the gitlab-plugin can't tell which credentials are available as credentials for this dropdown.

@4311021x You can't use the GitLab API token for cloning the repository. For this you have to use either a SSH key or a Username/Password combination. Furthermore this dropdown is part of the git-plugin not the gitlab-plugin. So the gitlab-plugin can't tell which credentials are available as credentials for this dropdown.

This should be called out I think in the docs. Right now it's assumed by most that this is what that is for.

Per comment by @4311021x I'm going to re-open this for resolution or documentation. You're right, I re-read that issue and it refers to the system config, which seems to be working.

If you want to use an api token to clone the repository, here's how:

  1. Create api token with api scope
  2. Create username/password credential in jenkins. Your gitlab username (the account the token is for) is the username and the token is the PW
  3. Make sure to use the https address, not ssh
  4. Use the token credential you created earlier in the git configuration

https://issues.jenkins-ci.org/browse/JENKINS-36863 This issue is closed but I am able to reproduce it in 2.19.4 Jenkins w/ Plain Credentials plugin installed trying to setup an ssh key in the github global configuration. Any idea when this might be addressed ?

@csbuild-c7ks7s github? This is the GitLab plugin...

@johnpbloch I found using the password of your gitlab account instead of the token as password with https address actually works.

Whoops - duplicate of https://issues.jenkins-ci.org/browse/JENKINS-36863

I don't think this is duplicated with the referred. That is in the system configuration, but this is in the job configuration, which is still there.

I wonder why this issue was closed? I still have this issue in a helm deploy of 2.222.4 in GKE. The credentials are not saved in the first place. when added manually under credentials and selected, it seems to not pick up the entry because after saving and reopening the same error shows up:

API Token for Gitlab access required

Was this page helpful?
0 / 5 - 0 ratings