WebHook
To create a webhook to trigger a Jenkins job when a push event happens in your Git repository, follow these steps:
Access the Jenkins web interface.
Open the configuration page for the Jenkins job you want to trigger.
Under the job configuration, click on the "Build Triggers" section.
Check the "GitHub hook trigger for GITScm polling" option.
Note: The exact wording may differ depending on the version of Jenkins or the plugin you are using. Look for an option that mentions triggering builds via a Git webhook or polling.
Save the job configuration.
Obtain the Jenkins job URL.
On the job details page, copy the URL from the browser's address bar.
Go to your Git repository settings.
Navigate to the repository settings or options page in your Git hosting platform (e.g., GitHub, GitLab, Bitbucket).
Look for the "Webhooks" or "Hooks" section in the repository settings.
Add a new webhook.
Click on the "Add webhook" or similar button to create a new webhook.
Configure the webhook settings.
Paste the Jenkins job URL you copied earlier into the "Payload URL" or "Endpoint URL" field.
Select the event that should trigger the webhook. In this case, choose "Push" or "Push event".
Optionally, you can configure other webhook settings, such as the content type or SSL verification.
Save the webhook.
Click on the "Save" or "Add webhook" button to save the webhook configuration.
Test the webhook.
Make a test push to your Git repository, either by committing and pushing changes or using a dummy commit.
Check the Jenkins job details page to verify if the webhook triggered the build.
Now, whenever a push event occurs in your Git repository, the webhook will send a request to the Jenkins job's URL, triggering a build. You can view the build status, logs, and other details in the Jenkins job details page.
Please note that the webhook configuration may vary depending on the Git hosting platform you are using. The steps mentioned here are general guidelines, and you may need to adapt them to the specific settings and options provided by your chosen Git hosting platform.
Last updated