"Secret text" Git credentials not showing up in Jenkins project Source Code Management section "Secret text" Git credentials not showing up in Jenkins project Source Code Management section git git

"Secret text" Git credentials not showing up in Jenkins project Source Code Management section


You can't use the Secret Text credential for the SCM step because the Github Personal Access Token is only supposed to replace your password. Not your user and password. Meaning your user is still required. In the Github documentation here you'll see it reads:

You can create a personal access token and use it in place of a password

And then below in section "Using a token on the command line" here it reads:

Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.

And it follows up with this example:

$ git clone https://github.com/username/repo.gitUsername: your_usernamePassword: your_token

If you extrapolate this to Jenkins, the sensible choice of credential type is still the User with password one.

So, simply create a credential of type User with password as you normally would and use your personal access token for the Password field.

User with password credential using personal access token instead


After installing the Credentials Bindings plugin, the Build Environment section of your build job Configuration page will include a new option to “Use secret text(s) or file(s)”. Enabling this option allows you add credential bindings where the Variable value will be used as the name of the environment variable that your build can use to access the value of the credential.

For example you create a secret: (the ***** = 12345)enter image description here

You can use it in the following way in your build:enter image description here

Output of echo $VAR in my case is *****. But you can use it as 12345 in your job. This is how you use secret text. The name says it all. The text remains secret but you can use it as unprinted variable in your job. This is for text, not for credentials.

If you want to reuse your credentials in your build it's recommended to use the "username and password conjoined". Here you can set a variable for your credentials. More info can be found here on how you can split username and password.