WebHook

To create a webhook to trigger a Jenkins job when a push event happens in your Git repository, follow these steps:

  1. Access the Jenkins web interface.

  2. Open the configuration page for the Jenkins job you want to trigger.

  3. Under the job configuration, click on the "Build Triggers" section.

  4. 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.

  5. Save the job configuration.

  6. Obtain the Jenkins job URL.

    • On the job details page, copy the URL from the browser's address bar.

  7. Go to your Git repository settings.

    • Navigate to the repository settings or options page in your Git hosting platform (e.g., GitHub, GitLab, Bitbucket).

  8. Look for the "Webhooks" or "Hooks" section in the repository settings.

  9. Add a new webhook.

    • Click on the "Add webhook" or similar button to create a new webhook.

  10. 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.

  11. Save the webhook.

    • Click on the "Save" or "Add webhook" button to save the webhook configuration.

  12. 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