To configure build triggers in Jenkins to be triggered when changes are pushed to a GitHub repository, you can follow these steps:
- Access Jenkins:
- Open your Jenkins dashboard in a web browser.
- Click on the name of the project (Freestyle project) you want to configure.
- In the project configuration, scroll down to the section labeled "Build Triggers."
- Check the box next to "GitHub Hook Trigger for GITScm polling." This option tells Jenkins to listen for GitHub webhook events and trigger builds when changes are pushed to the repository.
- Scroll down and click the "Save" or "Apply" button to save your project's configuration changes.
- Now you need to set up a webhook in your GitHub repository to notify Jenkins about repository events.
- Go to your GitHub repository.
- Click on "Settings" at the top-right corner.
- Navigate to "Webhooks" or "Webhooks & Services."
- Click "Add webhook" or similar.
- In the Payload URL, provide the URL of your Jenkins server's webhook endpoint. It usually looks like http://jenkins-server/github-webhook/.
- Select "application/json" as the content type.
- Choose the events that should trigger the webhook (e.g., "Push" events).
- Save the webhook.
- Make a small change to a file in your GitHub repository.
- Push the change to GitHub.
- Check your Jenkins project's build history. You should see a new build triggered by the webhook.
Please note that the exact steps and options might vary depending on your Jenkins version and configuration. Make sure your Jenkins server is accessible from the internet or your GitHub webhook configuration may fail to reach your Jenkins server.
Also, ensure you have configured proper security measures, as opening your Jenkins server to webhooks can be a security risk if not done correctly.