Skip to main content

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.

  • 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:

  1. From your Bitbucket repository click on Repository Settings > Webhooks > Add webhookA Bitbucket repository's Webhooks page
  2. Enter a Title for your webhook.
  3. Specify the URL. It must follow the pattern: https://<YOUR_JENKINS_SERVER>/bitbucket-hook/
  4. Select the following Triggers:
    1. In the **Repository** section, select **Push**.
    1. In the **Pull request** section, select **Created** and **Updated**.
    Webhook set up page

Now the webhook is set on the Bitbucket side. You can use it from your Jenkins instance.