Gitlab-plugin: No API token can be selected

Created on 1 Jul 2016  Â·  30Comments  Â·  Source: jenkinsci/gitlab-plugin

Gitlab plugin version: 1.2.5
Gitlab version: 8.8.1
Jenkins version: 1.648

I also setup loggin to more detail, but nothing relevant is logged. I followed the documentation, created a user in gitlab, added its API key to a credentials storage as Gitlab API token. But when I want to select it in Global settings and paths, I can't select anything. Dropdown menu shows only none.

image

Most helpful comment

I have the same issue with Jenkins 1.651, GitLab plugin 1.3.0, Credentials plugin 2.1.4.

The problem is that the URL

http://jenkins/descriptorByName/com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig/fillApiTokenIdItems

returns this:

{"values":[{"name":"- none -","selected":false,"value":""}]}

And nothing in the logs.

I was able to work around this with this trick:

  • Go to Credentials, create your GitLab API Token, and set the specific ID (e.g., "jenkins-to-gitlab").
  • On the Configure page, enable browser devtools (Cmd+Opt+I in Chrome), locate the <select> tag for this token field, expand it, find the <option> tag for "-none-" pseudo-token (the only <opton> tag there).
  • Replace its value & its text with "jenkins-to-gitlab" (the token id from the 1st step).
  • Save/apply the configuration.
  • Click the Test Connection button — it works (see "Success" message).

When you will be changing the configuration again, leave it as "-current-".

All 30 comments

When you set up the credential, what type did you specify? It should be "GitLab API Token."

There was the same Problem
This was resolved successfully upgrade Jenkins 1.648 to Jenkins 2.x

The credential was specified as GitLab API Token.
image

@kranian OK, thanks for the info. I have upgraded to the latest LTS version 1.651.3, but still the credentials isn't show. Does this work only on Jenkins 2.x?

No , I did the same with the lastest 1.651.3 , I seem to be not supported lastest 1.651.3
so I tried to upgrade to LTS Jenkis2.11
image

Same issue here on 1.649, Any chance this can be made to work on 1.x for now ?

major version upgrades require a lot of testing ...

I was worried Manager version upgrade. but After checking in at the official website as Jekins 2.x support backwards compatibility plugin.

I just updated the Jenkins war to the latest 2.11 version, but it still doesn't work, so I guess the problem is elsewhere.
Because I have also a docker version of Jenkins 2.3 which is works OK. Does anyone have any idea, what could it be?

Oh, I see, I think you need another solution

The issue can be closed. The plugin is working on 2.x release, I uninstalled the plugin, restarted the system and again installed the plugin and it started working.

@coder-hugo can you clarify the compatibility target for gitlab-plugin ?
using

  • plugin 1.2.5
  • jenkins 1.649
  • GitLab Community Edition 8.9.0 0d457d8

I can't select gitlab token credentials and therefore can't connect my jenkins to gitlab.
I have the token with gitlab token type
capture d ecran 2016-07-07 a 09 00 38
but I can't select them
capture d ecran 2016-07-07 a 09 01 59

Since i don't administer the jenkins instance myself, I'd like to know what to request :

  • upgrade to 1.651.3 (might be considered by the admins)
  • upgrade to 2. x (which means I'm out of luck)

Thanks

@jeantil during the development the gitlab-plugin runs in a Jenkins 1.609.3 and I can select a API token. So I'd assume there is an issue with the installed version of the credentials-plugin not with the version of the Jenkins itself.

@coder-hugo do we need to update the plugin's pom.xml to require a certain version of the credentials-plugin?

@coder-hugo thanks for your answer.
Which version of the credentials plugin should we be using ? The one installed at the moment is 2.1.4 and as far as I can tell it's the latest one.

@jeantil I just tested the plugin with a clean installation of Jenkins 1.649 and the credentials plugin 2.1.4 and I have no issues selecting the credentials. So the issue seems to be related to your Jenkins installation/configuration.

we're seeing the same issue, unable to select any credentials from the dropdown (even after a clean reinstall of the plugin). jenkins 2.13 plugin 1.3.0

@jeantil @paulatbipsync could you please check if the issue still exists with the current master? Either by building it with mvn clean package or by downloading it from the cloudbees Jenkins: gitlab-plugin-1.3.1-SNAPSHOT.hpi. I did a minor change (8da0bf2945d816778481c30ffd91a372b45fbb21) in the code that retrieve the available credentials but I'm not sure if this solves your issue as I can't reproduce it.

@coder-hugo Just tested the snapshot release you mentioned, but no luck. I'm experiencing this issue on jenkins 2.7.1 with plugin 1.3.0 + 1.3.1snapshot

I have the same issue with Jenkins 1.651, GitLab plugin 1.3.0, Credentials plugin 2.1.4.

The problem is that the URL

http://jenkins/descriptorByName/com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig/fillApiTokenIdItems

returns this:

{"values":[{"name":"- none -","selected":false,"value":""}]}

And nothing in the logs.

I was able to work around this with this trick:

  • Go to Credentials, create your GitLab API Token, and set the specific ID (e.g., "jenkins-to-gitlab").
  • On the Configure page, enable browser devtools (Cmd+Opt+I in Chrome), locate the <select> tag for this token field, expand it, find the <option> tag for "-none-" pseudo-token (the only <opton> tag there).
  • Replace its value & its text with "jenkins-to-gitlab" (the token id from the 1st step).
  • Save/apply the configuration.
  • Click the Test Connection button — it works (see "Success" message).

When you will be changing the configuration again, leave it as "-current-".

I have also the issue with
GitLab Plugin : 1.3.0
Credentials Plugin : 2.1.4
Jenkins : 1.651.3

I have the same issue with

Jenkins 2.7.1
GitLab Plugin 1.3.0
Credentials Plugin: 2.1.4

For those of you with this issue still, try installing the Plain Credentials plugin.

When I installed this, the "GitLab API token"-type credential I had saved became visible.

Just updated Jenkins to v2.17 from 1.6 and GitLab plugin to v1.3.0 and still having this...fixed using @nolar solution.

I have the same problem even though it looks like Plain Credentials plugin is already installed (automatically, I didn't install it) But there are many times I see the legendary warning message "No valid crumb was included in the request" , almost everywhere... Is tehre a way to use gitlab without gitlab-plugin?

@lacivert If you get this message "No valid crumb was included in the request" you have configured something wrong and this has nothing to do with the credentials.

@coder-hugo Thanks, I made jenkins run on my local windows machine well but I couldn't make it on a debian machine and with Gitlab plugins. The most relevant problem is this issue: nothing to seelct for gitlab token. And mainly, everywhere I see "No valid crumb...." message. In many pages, it works although it throws this message (I monitor it on dev-tools generally)

So how do I understand what's wrong?

  1. Can we make Jenkins work with gitlab without gitlab plugin?

@lacivert The message "No valid crumb was included in the request" comes from Jenkins itself not by our plugin. This crumb is used for protection against CSRF. In case this crumb wasn't included in your POST request (form submit) your changes won't be persisted. Which could lead to a similar behavior like this issue. But this error has nothing to do with this plugin. Maybe you have misconfigured your Jenkins or have installed a browser plugin which causes trouble.
As answer for your second question I can just say the following: Do you really think we would spend that much time for implementing a plugin for the GitLab Jenkins integration if this would work without a plugin?

Try turning off the Jenkins csrf prevention feature and see if this allows your jobs to trigger.

Had the same issue. I'm not able to add credential in task configure page (it doesn't show in the drop-down). I go to 'Credentials' in the main page, add the credentials there and then I go back to the task configure page, it shows up in the dropdown.

It only works with an SSH key guys, forget the token :/

go to create credential with gitlab api token, then select credential's name that you created. :D

Was this page helpful?
0 / 5 - 0 ratings