How to Integrate Your GitHub Repository to Your Jenkins Project
This explains how to add a GitHub Webhook in your Jenkins Pipeline that saves your time and keeps your project updated all the time.
You need to have setup CI/CD Pipelines on NERC's OpenStack by following this document.
What is a webhook?
A webhook is an HTTP callback, an HTTP POST that occurs when something happens through a simple event-notification via HTTP POST. Github provides its own webhooks options for such tasks.
Let's see how to configure and add a webhook in GitHub:
Go to your GitHub project repository.
Click on "Settings". in the right corner as shown below:
Click on "Webhooks" and then "Click "Add webhooks."
In the "Payload URL" field paste your Jenkins environment URL. At the end of this URL add /github-webhook/ using
http://126.96.36.199:8080/github-webhook/. Select "Content type" as "application/json" and leave the "Secret" field empty.
In the page "Which events would you like to trigger this webhook?" select the option "Let me select individual events." Then, check "Pull Requests" and "Pushes". At the end of this option, make sure that the "Active" option is checked and then click on "Add webhook" button.
We're done with the configuration on GitHub's side! Now let's config on Jenkins side to use this webhook.
That's it! in this way we can add a webhook to our job and ensure that everytime you commits your changes to your Github repo, GitHub will trigger your new Jenkins job. As we already had setup "Github hook tirgger for GITScm polling" for our Jenkins pipeline setup previously.