Triggering events from Bitbucket to Jenkins
This guide walks you through connecting your Bitbucket source code manager (SCM) with Jenkins, a CI/CD environment, through the use of webhooks. By connecting Bitbucket with Jenkins, you are able to customize jobs, such as your Semgrep job, based on push or pull events from Bitbucket.
Defining a Bitbucket webhook
One way to connect Bitbucket (Cloud or Server) to a Jenkins instance is defining a Bitbucket webhook. It allows you to trigger builds on Bitbucket's push and pull requests events.
Prerequisites
- You must install the Bitbucket Push and Pull Request plugin on your the Jenkins server. This method requires that your Jenkins instance is compatible with this plugin.
The steps to set up the webhook are the following:
- From your Bitbucket repository click on Repository Settings > Webhooks > Add webhook
- Enter a Title for your webhook.
- Specify the URL. It must follow the pattern:
https://<YOUR_JENKINS_SERVER>/bitbucket-hook/
- Select the following Triggers:
1. In the **Repository** section, select **Push**.
1. In the **Pull request** section, select **Created** and **Updated**.
Now the webhook is set on the Bitbucket side. You can use it from your Jenkins instance.