Triggering a Bamboo build from Bitbucket Cloud using Webhooks
Webhooks provide a way to configure Bitbucket Cloud to make requests to your server (or another external service) whenever certain events occur in Bitbucket Cloud. The purpose of this guide is to help you set up a Webhook that will trigger a Bamboo build from Bitbucket Cloud after a certain event. For example, you may want Bitbucket Cloud to trigger a Bamboo build when your repository receives a commit (aka post-commit trigger).
Procedure
- First configure the Bamboo plan to trigger with a Remote trigger: Actions > Configure plan > Triggers > Add trigger > Remote trigger.
- Bamboo requires you to add to the allowlist the IP addresses of the source of the request to trigger under the Trigger IP Addresses field (comma separated for each IP).
- The current list of Bitbucket Cloud IP addresses for outbound POST requests by Webhooks: Bitbucket Cloud IP Addresses
- CIDR Notation is only supported in Bamboo 5.14+
- Bamboo's IP allowlist also inspects the X-Forwarded-For HTTP header to determine the origin of the request. If you have a reverse proxy forwarding requests to your Bamboo instance, depending on its configuration, you may also need to add to the allowlist the IP address of the Proxy Server.
- Add a Webhook to your Bitbucket Cloud repository: Bitbucket Cloud > Repository > Settings > Webhooks > Add webhook.
- Title: Select any title for your Webhook that aptly describes it.
- URL: Enter the URL of the Bamboo API to trigger a plan:
BAMBOO_URL/rest/triggers/1.0/remote/changeDetection?planKey=PLAN-KEY&skipBranches=false
- Replace
BAMBOO_URL
with the URL of your Bamboo instance. - Replace
PLAN-KEY
with the key of the plan you wish to trigger. ThePLAN-KEY
is visible in the URL when browsing the plan in Bamboo. E.g. https://bamboo.atlassian.com/browse/PLAN-KEY - skipBranches true / false will determine whether change detection will be triggered by this event for every branch on the plan (false), or just the plan key specified (true).
- Replace
- Triggers: Select the event(s) you want the Webhook to activate on. E.g. Repository Push.
- Save.
That's it! If you find your Webhook doesn't appear to be working – the best place to start troubleshooting is by viewing the request and response at Bitbucket Cloud > Repository > Settings > Webhooks > View requests.