All Courses
How to Integrate GitHub-Webhooks with Jenkins?

In this tutorial, you will learn how to Integrate GitHub-Webhooks with Jenkins. For automation, trigger a building job when a new commit is pushed to GitHub. In certain scenarios, we use three different processes to trigger a job in Jenkins.

  • Build periodically.
  • Poll SCM
  • web hooks.

In particular, new changes submitted to Github’s Jenkins job will be triggered automatically
Jenkins job settings in the Github repository.

prerequisites :

  • Jenkins should run in your machine.
  • git hub account.
  • git hub repository

If you are running Jenkins on a local machine like (localhost: 8080), the IP address will be:
Configure as public IP or DNS. Otherwise, the Jenkins server will not be able to connect to GitHub.
To do this, you can make it localhost via NGROK. Download ngrok Run the ngrok.exe file using the local host and port.

After successful download, you need to register with ngrok using the following link.

How to Integrate GitHub-Webhooks with Jenkins? - Download ngrok

If you log in successfully, you will receive a token with the execution of the step.

Open the folder where you unzipped ngrok.exe. Run the following command:

> ngrok.exe authtoken <YOUR_AUTH_TOKEN>

if Linux

./ngrok authtoken <YOUR_AUTH_TOKEN>

it will give results like the below.

How to Integrate GitHub-Webhooks with Jenkins? - Config

Then run HTTP and the port number with the ngrok command as shown below.

> ngrok.exe http 80

if Linux

./ngrok http 80

this will give output like the below.

How to Integrate GitHub-Webhooks with Jenkins? - stop process

if you to stop or quiet press ctrl+c.

Here is This is the public domain of the system that needs to be configured
These are yours at GitHub webhooks.
Now your public DNS is ready and you can jump to your Jenkins configuration.

goto jenkins home page select which project need to be trigger with the project –> goto configure –> goto general section select github project enter the github project URL without .git extention –> goto build trigger section select a check box GitHub hook trigger for GITScm polling.

if not configure earlier github and jenkins do it in scm section select and git and enter url of
github repository and credentials of your github.

then apply and save the changes.

Next, you need to change the configured global security to allow CSRF.

Go to Jenkins Administration –> Configure Global Security –> CSRF Protection –> Disable Prevention Option Cross-site request forgery exploit.

Then go to your Github account and select the repository you want to create using the webhook.
Go to Settings –> Select Webhook –> Enter the payload URL created by ngrok and Update the webhook.

http:/// github-webhook/

Then click Webhook and the green checkmark indicates that the webhook was successful

Then modify something in the repository with git bash or github and commit the code let Check if the trigger is created automatically in Jenkins and also check the output of the ngrok console.

You have successfully configured the Jenkis and Github webhooks to automate the triggers a build.