Jenkins: Invalid Credentials

Note: please feel free to email me at ashley.tharp@gmail.com with questions, or leave a comment to let me know any adjustments that can be made to make this tutorial better. :)

Invalid credentials: https://api.github.com/user {“message”:”Bad credentials. The API can’t be accessed using username/password authentication. Please create a personal access token to access this endpoint: http://github.com/settings/tokens","documentation_url":"https://docs.github.com/articles/creating-a-personal-access-token-for-the-command-line"}

Here’s how to fix this:

Github deprecated logging in with a user name and password so what you need to do is to create a “personal access token”

Go to here:

github.com/settings/tokens

It looks like this at the top of the page:

You can create a new one by clicking the “Generate New Token” button

You should see a page that looks like this

enter a name like “my build server” or something you can remember so that you don’t confuse it with your other access tokens.

Check the box that says “repo”

Click the “Generate Token” button at the end of the form

It will show you a screen like above. Click the little clipboard icon to copy the token and put it somewhere safe. THIS IS YOUR ONLY CHANCE TO SAVE THIS TOKEN STRING. So, you should probably save it in a file somewhere, or else you will have to generate a new token the next time. Perhaps email it to yourself or something. If you lose it, it’s not the end of the world though, you can just as easily create a new one by doing these steps again.

In your Jenkins Pipeline Configuration settings you’re going to find the “Pipeline” section and set it to “Pipeline script from SCM” (that just means pull my Jenkinsfile from version control)

and you will have SCM set to “Git”

Click the button “Add”

Put your Github username in the “Username” field,

Put the Personal Access Token you just copied using the little clipboard icon in Github in the section labelled “password”

I initially found this confusing, and I kept putting my Github password here, but that is not correct, so don’t get thrown off by the labelling here, it’s where you copy the Personal Access Token from Github.

Click the Add Button to finish.

And you’re set, that should fix your authentication issue.

Research and Development | Dev Ops | Software Engineer | Topaz Labs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store