Skip to content

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

Closed
@krisgraham

Description

@krisgraham

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

Activity

krisgraham

krisgraham commented on Aug 9, 2016

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

krisgraham commented on Aug 10, 2016

@krisgraham
Author

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

dblessing commented on Aug 11, 2016

@dblessing

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

dblessing

dblessing commented on Aug 11, 2016

@dblessing
krisgraham

krisgraham commented on Aug 11, 2016

@krisgraham
Author

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

samskiter

samskiter commented on Aug 31, 2016

@samskiter

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

coder-hugo

coder-hugo commented on Aug 31, 2016

@coder-hugo
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

samskiter commented on Aug 31, 2016

@samskiter

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

0xC4N1

0xC4N1 commented on Sep 5, 2016

@0xC4N1

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

coder-hugo commented on Sep 5, 2016

@coder-hugo
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

LongLiveCHIEF commented on Sep 8, 2016

@LongLiveCHIEF

@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

krisgraham commented on Sep 8, 2016

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

johnpbloch commented on Feb 14, 2017

@johnpbloch

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

csbuild-c7ks7s commented on Mar 23, 2017

@csbuild-c7ks7s

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

omehegan commented on Mar 23, 2017

@omehegan
Member

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

pianyao

pianyao commented on Jun 16, 2017

@pianyao

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

omehegan

omehegan commented on Jan 23, 2018

@omehegan
Member

Clarified in 438e6cc

5452

5452 commented on Apr 23, 2019

@5452

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

VGerris commented on Jun 3, 2020

@VGerris

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @johnpbloch@VGerris@5452@pianyao@krisgraham

        Issue actions

          Cannot add a "GitLab API Token" as a credential · Issue #388 · jenkinsci/gitlab-plugin