Pascal Widdershoven – 5 November 2013
443 words in about 2 minutes

We at Kabisa are pretty heavy Jenkins users. We live and breathe Test Driven Development, so a CI server continuously running our tests and building our apps is vital.

About a year ago we switched some projects over to Travis CI, because it had such awesome Github pull request integration.

Nowadays it’s possible to make Jenkins build your GitHub pull requests as well, let me show you how.

Installing the GitHub Pull Request Builder Plugin

To get things going you’ll need to install the GitHub Pull Request Builder Plugin. To do this go to JenkinsManage JenkinsManage Plugins and click on the Available tab. Search for GitHub Pull Request Builder and install it.

Configuring the GitHub Pull Request Builder Plugin

After installing the plugin and rebooting your Jenkins it’s time to configure the plugin. Go to JenkinsManage JenkinsConfigure System and scroll down to the GitHub Pull Requests Builder section.

global configuration

To get going you only need to enter a GitHub access token for the GitHub user you would like to access your GitHub repositories from Jenkins. It’s probably a good idea to use a dedicated user for this purpose.

Beware that the user Jenkins will be using to connect to GitHub must be either the repo owner or have “Push, Pull & Administrative” permissions.

Note: if you don’t have an access token yet you can fill in your GitHub username and password under “Advanced…” and have Jenkins create the access token.

Enabling Jenkins Projects to Build GitHub Pull Requests

Now to actually allow Jenkins to build your projects pull requests we’ll need to setup a new Jenkins Project and configure it as follows:

  1. Create a new project;
  2. In the GitHub project field fill in the URL to your GitHub project, e.g. https://github.com/<username>/<project>/
  3. Under Source Code Management select Git and enter the fields as follows

project configuration git

  1. Under Build Triggers make sure to check the following settings and white list some users:

project configuration triggers

  1. Now perform your regular setup of what Jenkins should actually do, e.g. run rspec, cucumber etc. At Kabisa this step usually only involves running bin/ci, a script under version control running the entire testsuite.

  2. Now the final step to get things going is to enable the Set build status on GitHub commit post-build action

project configuration postbuild actions

Now whenever you open a new pull request or add some commits to an existing pull request Jenkins will try to perform a merge build and report the result to GitHub. Now all your pull requests should look like this:

github

Happy coding!

Pascal Widdershoven

Full Stack Developer • Github: pascalw • Twitter: @_pascalw