Difference between revisions of "GitHub/Jenkins: Setting up Webhooks"

From Gcube Wiki
Jump to: navigation, search
(What is a webhook?)
(Prepare GitHub repository)
Line 17: Line 17:
  
 
Enter the following URL: https://jenkins.d4science.org/github-webhook/
 
Enter the following URL: https://jenkins.d4science.org/github-webhook/
 +
 +
See https://help.github.com/en/github/extending-github/about-webhooks.
  
 
= Update Jenkins job with GitHub configuration =
 
= Update Jenkins job with GitHub configuration =

Revision as of 06:16, 26 November 2019

What is a webhook?

A webhook is a mechanism to automatically trigger the build of a Jenkins project upon a commit pushed in a Git repository.

This guide details the steps to have Jenkins automatically create a build if it detects changes to a GitHub repository. This can be a very useful improvement to continuous integration setup with Jenkins because this method is only telling Jenkins to attempt a new build when a change is detected rather than polling on an interval, which can be a very inefficient.

For more information, see https://developer.github.com/webhooks/.

GitHub Plugin on Jenkins (only for Jenkins admins)

Prepare GitHub repository

We need to add a service to call the Jenkins GitHub webhook on a push. In the GITHub repository, do this:

  1. go to settings -> integrations & Services
  2. add a new service. The Jenkins GitHub plugin service should be in the list of available services.

Enter the following URL: https://jenkins.d4science.org/github-webhook/

See https://help.github.com/en/github/extending-github/about-webhooks.

Update Jenkins job with GitHub configuration

In the ‘General’ section of the job configuration check the Github project tick box and enter the URL to the repository that you configured in step 2.

Next update the Source Code Management section, first set the repository URL (note the format git@github.com:{YOUR_REPO}. You can also specify the branch you would like to use.

The last step is to tell Jenkins to build when the Github hook is called, select the highlighted option below in the Build Triggers section.

That’s it! Your Jenkins build should now be triggered whenever a push is made to your repository.

Back to the CI guide.