Configuring Bitbucket Webhooks for Jenkins Multi‑Branch Pipeline to Trigger Builds on Pull Requests
This guide explains how to set up Bitbucket webhooks and Jenkins Bitbucket Branch Source plugin so that every Pull Request automatically triggers a Jenkins multi‑branch pipeline build, improving build speed and reliability.
Jenkins multi‑branch pipelines can automatically build any branch or Pull Request (PR) in a Git repository, but when the Bitbucket webhook is not configured the build may not be triggered.
Problem: The author experienced two incidents where creating a PR did not start a Jenkins build, despite no changes to Jenkins or the Bitbucket Branch Source plugin.
Solution: Instead of relying on the plugin‑generated webhook, manually add a Bitbucket webhook that points to Jenkins.
Webhook name: test-multibranch
Webhook URL: http://localhost:8080/multibranch-webhook-trigger/invoke?token=test-multibranch
Test connection: returns 200 (successful)
Events: Pull Request – Opened, Merged, Declined, Deleted
Active: enabled
After configuring the webhook in Bitbucket (see screenshots), the Jenkins integration works as follows:
When a PR is opened, Jenkins creates a corresponding PR job (e.g., PR‑123 ) and starts the build.
When the PR is merged, the job is automatically removed.
When the PR is declined or deleted, the job is also removed.
Merged branches appear crossed out in gray and cannot be rebuilt, while develop and master branches remain buildable manually or automatically.
Event notes: The author chose not to enable the Modified event because it caused excessive builds for pending PRs, consuming build resources for several hours per run. The Modified event fires when a PR’s description, title, or target branch changes, which can be useful but was unnecessary for the current workflow.
Additional webhook events (e.g., for the main branch) can be added as needed, and a simple trigger step can be placed inside the Jenkins Pipeline if daily builds are sufficient.
DevOps Engineer
DevOps engineer, Pythonista and FOSS contributor. Created cpp-linter, commit-check, etc.; contributed to PyPA.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.