Building GitHub Pull Requests with Jenkins

Me 2020 square

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.<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:


Happy coding!

Me 2020 square

Pascal Widdershoven

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

At Kabisa, privacy is of the greatest importance. We think it is important that the data our visitors leave behind is handled with care. For example, you will not find tracking cookies from third parties such as Facebook, Hotjar or Hubspot on our website. Only cookies from Google and Vimeo are used in order to improve the user experience of our visitors. These cookies also ensure that relevant advertisements are displayed. Read more about the use of cookies in our privacy statement.