Over the last iteration we spent some time perfecting our continuous integration environment. We’ve started using Jenkins (the CI environment previously known as Hudson), and so far we’re pretty happy. One thing that vexed us for a while was getting a GitHub service hook to trigger our builds.
Here’s what we had to do:
1. Create a “GitHub” account with Jenkins.
The credentials from this “github” user account are required for GitHub to gain access to the build URL. We’re using the built-in Jenkins user database with matrix-based authorization. So we added a “github” account using the “sign up” functionality, and then gave that user “Overall: Read” and “Job: Read” permissions. We’re not totally sure why these particular permissions are required, but we are sure that the URL-based build trigger doesn’t work without them!
2. Configure Remote Build Trigger
On the “Configure” section of the Jenkins job you’re setting up, check the “Trigger builds remotely” box (under the “Build Triggers” section), and set some long random authentication token:
3. Configure a Post-Receive URL at GitHub
Here’s what the URL for GitHub should look like:
GITUSER and GITPASSWORD pertain to the “github” user you created with Jenkins. Also, don’t forget to include the port Jenkins is running on if it’s not port 80. Add this to your GitHub repository by visiting the “Service Hooks” Admin section of the project you’re setting up. Here’s about what it should look like:
Hopefully this saves you some time if you are looking to use Jenkins and want to use a GitHub service hook to trigger your builds.
And let us know if you have any questions, comments, or suggestions! Thanks.