Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Jenkins - Add Git Webhook Access Token

I recently had to re-deploy Jenkins (version Jenkins 2.361.2) and noticed that my git webhooks for my pipeline would no longer work because they now need to provide a token for security. These webhooks were used in order to have Github notify Jenkins that there was a change, and it may need to run the pipeline. Luckily, this is easily resolved by executing the following steps:

Steps

On the Jenkins landing page, click Manage Jenkins.


Click on Configure Global Security.


Scroll down to Git plugin notifyCommit access tokens and click the button to Add new access token.


In the form field, enter a name for your project that the token will act as a webhook for. Then click Generate.

Technically, one could create just one token for all of your repositories, however, this would mean that if you ever needed to revoke a repository from triggering Jenkins, you would end up revoking all of your projects, not just one. It is better to save yourself from this future pain by creating one token per project/repository.


Copy the token (1), before then clicking Save.


Now you just need to update your webhook URL to include it by appending

&token=yAccessTokenHere

E.g.

http://jenkins.mydomain.com:8080/git/notifyCommit?url=https://github.com/my-github-username/name-of-my-repository&token=myAccessTokenHere
Last updated: 28th October 2022
First published: 28th October 2022

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch