OpsInit: Adding a Github webhook in Jenkins Pipeline

Reading Time: 3 minutes

Have you ever tried adding GitHub webhook in Jenkins?? In this blog, I will be demonstrating the easiest way to add a webhook in our pipeline.

First, let’s see what is a webhook??
The concept of a WebHook is simple. A WebHook is an HTTP callback: an HTTP POST that occurs when something happens. GitHub webhooks in Jenkins is used to trigger our build whenever a developer commits something on the master branch.

Let’s see how to add build a Webhook in GitHub and then add this webhook in Jenkins.


    1. Go to the project repository.
    2. Go to settings on the right corner.
    3. Click on webhooks.
    4. Click Add webhooks.
    5. Write the Payload URL

https://<Jenkins Server>



Payload URL:-  Is the URL where our Jenkins is running.
Content type:- The kind of data we want in our webhook. JSON, XML, etc.
Secret:- Used to secure our webhook we can provide a secret in our webhook and ensure that only applications having this webhooks can use it.
SSL verification:- This SSL Checker will help us diagnose problems with SSL certificate installation. We can verify the SSL certificate on our web server to make sure it is correctly installed, valid, trusted and doesn’t give any errors to any of our users.

When shall these webhooks be triggered?

  1. Just the push event:- Only send data when someone pushed into my repository.
  2. Send me everything:- If there is any pull or push event in our repository we will get notified.
  3. Let me select individual events:- We can configure for what events we want our data.

Click Create and a webhook will be created.


But there is a problem, we have to take care of if we are running Jenkins on localhost then writing https://localhost:8080/github-webhook/ will not work because webhooks can only work when they are exposed to the internet.

So, if we want to make our localhost to be exposed to the internet then we can use the ngrok tool. Refer to this link.

Now let’s see how to use this webhook into our Jenkins.


  1. Go to Manage Jenkins ->Configure System
  2. On scrolling down, we will find GitHub Pull Requests checkbox.
    In Published Jenkins URL:-  add the repository link
  3. Click on Save.


Now go to Jenkins Pipeline and select GitHub hook trigger for GITScm polling.


In this way, we can add Webhook to our job and ensure that everytime a developer commits code to GitHub our build will get triggered.

I hope this blog was helpful in adding Github webhook in Jenkins.

Written by 

Sachin is a software consultant having more than 0.5 years of experience. He loves to learn trending technologies. Sachin is familiar with languages such as Java, Scala and is currently working on DevOps technologies /tools like Kubernetes, Jenkins, Ansible, Docker, Bamboo.