Ok, here’s how you can set up Jenkins to set GitHub build statuses. This assumes you’ve already got Jenkins with the GitHub plugin configured to do builds on every push.
-
Go to GitHub, log in, go to Settings, Developer Settings, Personal access tokens and click on Generate new token.
-
Check repo:status (I’m not sure this is necessary, but I did it, and it worked for me).
-
Generate the token, copy it.
-
Make sure the GitHub user you’re going to use is a repository collaborator (for private repos) or is a member of a team with push and pull access (for organization repos) to the repositories you want to build.
-
Go to your Jenkins server, log in.
-
Manage Jenkins → Configure System
-
Under GitHub Web Hook select Let Jenkins auto-manage hook URLs, then specify your GitHub username and the OAuth token you got in step 3.
-
Verify that it works with the Test Credential button. Save the settings.
-
Find the Jenkins job and add Set build status on GitHub commit to the post-build steps
That’s it. Now do a test build and go to GitHub repository to see if it worked. Click on Branches in the main repository page to see build statuses.
You should see green checkmarks: