Skip to content
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

Cannot add a "GitLab API Token" as a credential #388

Closed
krisgraham opened this issue Aug 9, 2016 · 19 comments
Closed

Cannot add a "GitLab API Token" as a credential #388

krisgraham opened this issue Aug 9, 2016 · 19 comments

Comments

@krisgraham
Copy link

krisgraham commented Aug 9, 2016

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).

@krisgraham
Copy link
Author

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.

@krisgraham
Copy link
Author

krisgraham commented Aug 10, 2016

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 :)

@dblessing
Copy link

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

@dblessing
Copy link

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

@krisgraham
Copy link
Author

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

@samskiter
Copy link

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

@coder-hugo
Copy link
Contributor

@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.

@samskiter
Copy link

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

@0xC4N1
Copy link

0xC4N1 commented Sep 5, 2016

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.

@coder-hugo
Copy link
Contributor

@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.

@LongLiveCHIEF
Copy link

@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.

@krisgraham
Copy link
Author

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.

@johnpbloch
Copy link

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

@csbuild-c7ks7s
Copy link

csbuild-c7ks7s commented Mar 23, 2017

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 ?

@omehegan
Copy link
Member

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

@pianyao
Copy link

pianyao commented Jun 16, 2017

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

@omehegan
Copy link
Member

Clarified in 438e6cc

@5452
Copy link

5452 commented Apr 23, 2019

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.

@VGerris
Copy link

VGerris commented Jun 3, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests