Triggering Jenkins builds from a git hook
I use Jenkins CI to build a number projects as part of a continuous integration system. I wanted to set things up so that, after each commit to a git repository containing one of these projects, the new code would be checked out and rebuilt by Jenkins (as well as collecting metrics and performing various other tasks). It turns out there’s a very easy way to do this using Git hooks and Jenkins remote build triggers.
Start by setting up a remote build trigger in a Jenkins project. This will enable a URL that, when fetched using an HTTP GET request, will cause Jenkins to build the project. To set things up, visit the Configure page for the project in Jenkins and, under Build Triggers, make sure the Trigger builds remotely option is checked. You’ll need to specify an authentication token to pass as a query parameter. I usually use md5sum to generate an MD5 message digest since they’re random(-ish) and URL-friendly. Make note of the URL that is displayed; that’s what you