This post will detail 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 your 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 little bit inefficient.
There are a few steps necessary to get this process working correctly that I would like to highlight in case I have to do this again or if anybody else would like to set this up. Most of the guides that I found were very out of date so their instructions were a little bit unclear and misleading.
The first step is to configure Jenkins to talk to GitHub. You will need to download and install the GitHub plugin (I am using version 1.8 as of this writing). Manage Jenkins -> Manage Plugins -> Available -> GitHub plugin
After this is installed you can either create a new build or configure an existing build job. Since I already have one set up I will just modify it to use the GitHub hook. There are a few things that need to be changed.
Then you will then have to tick the box indicated below – “Build when a change is pushed to GitHub”
Also note that Jenkins should have an SSH key already associated with the desired GitHub project.
You’re pretty close to being done. The final step is to head over to GitHub and adjust the settings for the project by creating a webhook for your Jenkins server. Select the repo you’re interested in and click Settings. If you aren’t an admin of the repo you will not be able to modify the settings, so talk to an owner to either finish this step for you or have them grant you admin to make the change yourself.
The GitHub steps are pretty straight forward. Open the “Webhooks & Services” tab -> choose “Configure Services” -> find the Jenkins (GitHub plugin option) and fill it in with a similar URL to the following:
- http://<Name of Jenkins server>:8080/github-webhook/
Make sure to tick the active box and ensure it works by running the “Test Hook”. If it comes back with a payload deployed message you should be good to go.
GREAT content! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep
ReplyDeletesharing… DevOps Online Training
DevOps Training
DevOps Online Training
it was so good to read and useful to improve my knowledge as updated one, keep blogging.Thanks for providing wonderful information with us, keep share content on setting up a github.I like your post very much.
ReplyDeleteDevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
Good post and informative. Thank you very much for sharing this good article, it was so good to read and useful to improve my knowledge as updated, keep blogging.yours blog was excellent and really enjoyed.Thanks for sharing and mainting blogging
ReplyDeleteoracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
oracle online training
hadoop training in chennai
hadoop training in bangalore