Reputation: 2090
I have Jenkins 2.204.2 and want to configure a project with my git credentials for our gitlab server.
I created under Jenkins > Credentials > System > Global credentials
an entry with a secret key.
Nevertheless, if I create a freestyle project and set git
as source code management, the opttions for Credentials
remain empty.
Also if I use the Add
button next to the credentials options and add the same secret key again, this does not show up in the options (though the new entry is shown in the Global credentials
menu).
How can I configure the credentials to be used for Jenkins ? What do I miss, that I cannot select my created credentials ?
Upvotes: 12
Views: 18220
Reputation: 171
In my case it looks like something related to the SSH Build Agents.
In a fresh new Jenkins setup it downloaded the version 2.948.vb_8050d697fec, which didn't show the credential list. After reinstalling the Jenkins without this plugin, and then using the cli to install the version 2.916.vd17b_43357ce4 everthing workes well.
You can find the command to setup it on this webpage:
https://plugins.jenkins.io/ssh-slaves/releases/
Upvotes: 0
Reputation: 6791
When creating it, try changing its Kind
to Secret text
(at <JENKINS_URL>/manage/credentials/store/system/domain/_/newCredentials
) rather than the default Username and Password
. The contents stay the same (generated on Github's website as Github Personal Access Token
(docs), but this time no login, just Secret).
This enabled the display of the token in the drop-down menu of the GitHub Plugin (GitHub servers > Credentials at <JENKINS_URL>/manage/configure
).
Upvotes: 2
Reputation: 4414
To use the git protocol (and not the https protocol) your Jenkins credentials must be of type "SSH Username with private key".
Even so, those credentials won't appear in the dropdown list due to this known issue: likely you have installed the "Authorize Project" Plugin and in the "Configure Global Security" > "Project Default Build Authorization" section, "Strategy" field configured to "Run as specified user" (and a user) or "Run as anonymous". As a workaround for the issue, you can select "Run as SYSTEM" and the SSH credentials will appear in the list.
See:
Why credentials are not listed in the GIT SCM section? https://support.cloudbees.com/hc/en-us/articles/360017499672-Why-credentials-are-not-listed-in-the-GIT-SCM-section-
Upvotes: 11