Jenkins + Github + Webhook = Trigger Jenkins Build

The quick blog post will list the steps on how to trigger Jenkins build on repository changes. This method automatically triggers Jenkins build when a change is detected rather than polling on an interval, which is inefficient.

  1. Configure Jenkins to talk to GitHub. Download and install the GitHub plugin. Manage Jenkins -> Manage Plugins -> Available -> GitHub plugin
  2. There are a number of different authentication options in the ‘Security Realm’ section of Manage Jenkins -> Configure System. Depending on your setup, these steps could differ, but in essence you need to create a new user for Github
  3. In the Authorization section, choose Project-based Matrix Authorization Strategy, so that you can give project-level permissions to the Github user. You’ll probably deny access to everything for anonymous users, then grant just one permission here for Github: ‘Overall/Read’.
  4. In the configuration for the job that will be automatically triggered, tick Enable project-based security and then grant Job/Read and Job/Build to Github.
  5. Add the hooks to Github. And that’s it.
    1. git_add_hook