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.
By default, Ansible will continue executing actions as long as there are hosts in the batch that have not yet failed. The batch size for a play is determined by the serial parameter. If serial is not set, then batch size is all the hosts specified in the hosts: field. In some situations, such as with the rolling updates described above, it may be desirable to abort the play when a certain threshold of failures have been reached. To achieve this, you can set a maximum failure percentage on a play as follows:
In the above example, if more than 3 of the 10 servers in the group were to fail, the rest of the play would be aborted.