DevOps Tutorial-3 Triggering CI Build with Github Push Notifications



In this tutorial we will learn about triggering the CI Build with Git Hub Push notifications or Pull notifications automatically by using Jenkins Web Hook URL.
The Jenkins Web Hook URL needs to be added in the GitHub Repository. These Web Hook helps to detect changes in the Git Hub and trigger the Jenkins JOB automatically. Please follow the steps to enable this in Git Hub and Jenkins.

Enable Communication between Jenkins and Git Hub

1. Access the Jenkins URL.
2. Navigate to Manage Jenkins->Configure System->Git Hub Section. Click on Add to provide the Credentials as mentioned below. For Generating the Secret Text Click on this link and generate the Token and update accordingly.
ID: Github1

New personal access token

New personal access token


Jenkins->Git Hub Server

Jenkins->Git Hub Server


3. Navigate to the Git Hub Repository URL click on Integration Services and Add Service as Jenkins(GitHub plugin).
Git Hub Integration Plugin

Git Hub Integration Plugin


4. Configure the Web Hook in the Git Hub Repository Settings as shown below:
Payload URL : Jenkins URL + /github-webhook/
Git HubWebhook Configuration

Git HubWebhook Configuration

5. Provide the Secret Key generated in the Step 2 nothing but the Token. In addition to that select the Events to trigger this Web Hook.

  • Enable Pushes
  • Enable Pull request reviews

Git Hub Events Push and Pull

Git Hub Events Push and Pull

6. Select the Active Checkbox and Add the Web Hook.

7. Navigate to Git Hub Repository URL update the Review Comments for the Pull Request.

8. Access the Web Hook under the Repository Settings and check the payload information.

Web Hook Payload

Web Hook Payload

9. Click on Redeliver Button to send the payload again and verify the response.

Issues

Stack Over Flow: Web Hook Connectivity Issues to Jenkins

Conclusion:

Using Web Hooks in Git Hub we can configure events such as Push and Pull which triggers the Jenkins Job automatically.

References

DevOps tutorial Series

Leave a Reply

Your email address will not be published. Required fields are marked *