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.
- Configure Jenkins to talk to GitHub. Download and install the GitHub plugin.
Manage Jenkins -> Manage Plugins -> Available -> GitHub plugin
- 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
- 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’.
- 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.
- Add the hooks to Github. And that’s it.