Automating a build with triggers
The best way to allow your CI build to trigger when you make changes to your code is to use a post-commit webhook. We looked at such an example in the GitHub Actions workflow. Let’s try to automate the build with triggers in the case of Jenkins. We’ll have to make some changes on both the Jenkins and the GitHub sides to do so. We’ll deal with Jenkins first; then, we’ll configure GitHub.
Go to Job configuration | Build Triggers and make the following changes:
Figure 11.16 – Jenkins GitHub hook trigger
Save the configuration by clicking Save. Now, go to your GitHub repository, click Settings | Webhooks | Add Webhook, and add the following details. Then, click Add Webhook:
Figure 11.17 – GitHub webhook
Now, push a change to the repository. The job on Jenkins will start building:
Figure 11.18 – Jenkins GitHub webhook...