DEV@cloud » GitHub Commit Hooks HOWTO

GitHub Commit Hooks HOWTO

Last modified by Nicolas De Loof on 2013/02/28 14:29

If you would like builds to start immediately after a commit, you can use GitHub post-commit hooks to ping Jenkins to queue up a build whenever someone pushes to your repository.

There are just a few steps needed:

  1. Install the GitHub plugin.
    • Go to Manage Jenkins -> Manage Plugins -> Available [tab]. 
    • Choose the github plugin, and click the "Install Button" at the bottom of the page. 
    • Once the plugin is installed, restart Jenkins as directed.
  2. Next, configure the GitHub plugin with your GitHub credentials if you would like the plugin to automatically setup commit hooks in repositories that you administer.  Select "Let Jenkins auto-manage hook URLs" and enter your GitHub credentials.

    Configuring the GitHub plugin


  3. Then, just edit your job configuration to enter your GitHub repository URL, Name and Email.

    Git Location Configuration


  4. Next, choose "Build when a change is pushed to GitHub" and press the Save button at the bottom of the page.

    GitHub Build Trigger Configuration


  5. Finally, do an initial build of your project.

Voila! Now, any push to a branch in your GitHub repository will result in a build of any jobs configured to follow that branch.

Next: You may also want to configure your private GitHub repositories for access by your DEV@Cloud Jenkins builds while you have GitHub open.

Also - if you are interested - you can also have github pull requests build and be validated as they come in - read on.

Alternative Configuration

If you would prefer not to enter your GitHub credentials, you can choose "Manually Manage Hook URLs" in step two, and then set up the commit hook manually for each repository you are monitoring with Jenkins.

To do this, go to your repository on github.com, click the "Admin" button at the top of the page, and choose "Service Hooks". Then choose "Post-Receive URLs" and enter the url to your Jenkins instance's GitHub webhook which is "https://<domain-id>.ci.cloudbees.com/github-webhook/" and should be the same for every repository or job.

Capturedecran2013-02-28a15.28.29.png

Created by Ryan Campbell on 2011/07/20 22:17