One of the things people love about travis-ci is it will build pull requests, but most people don’t realize Jenkins can do pull requests as well. It is also very simple to configure Jenkins to do pull requests using the correct plugin.
Install the Plugin
Install this plugin through the manage Jenkins admin section.
Configure Github User
This is fairly simple. Follow the trail of links then add the relevant information. Make sure you have a user you want to access github with, and they have the appropriate permissions for the repos.
- Manage Jenkins
- Configure System
- Find Github pull requests builder Configuration Section
- Fill in the relevant information similar to the image below
Configure Your Git Pull
You need to configure where Jenkins pulls from Github to build pull requests. Specifically Github stores all the pull requests in a “secret” location. It isn’t really secret, but most people don’t explore where refs are stored. So adding the following to the correct refspec is a must. In the advanced tab of the your git configuration add the following:
In the branch specifier section add:
Here is what that section should look like:
You also need to set Build triggers and add users to the whitelist so people whom submit pull requests can have their pull requests automatically build. If you don’t add people to the white list you will need to tell Jenkins to build the PR.
If everything was configured correctly. Your pull requests will look like this at the bottom of the PR:
Pull requests create an awesome workflow, and really help teams collaborate on a lot of different parts of code. The real problem has been, for a while, that the Pull Requests are outside the main refspec and will not build on a push. So with the pull request builder plugin it targets the location the PRs are at. The best part is it tells you the build status of the build inside the PR, similar to Travis-ci. If you aren’t using Jenkins or Github PR’s I recommend starting.