Trigger Azure Piplines build based on BitBucket Pull Request

Karthik Kotha June 11, 2019

Does anyone know how to trigger Azure Pipeline builds (not bitbucket builds) based on Bit Bucket PRs?

3 answers

0 votes
Ray Depew April 4, 2023

We came up with two workarounds.

1. PowerAutomate. We created a Microsoft Power Automate flow to do what we wanted. The flow uses the Bitbucket Connector to capture a WebhookPullRequestMergedResponse, and the Azure Devops Connector to queue an Azure Pipelines build. Unfortunately, these two connectors require a premium license, and we're not willing to pay for that right now. So, even though this is a good solution, we're not going to pursue it further.

2. Our own little webserver. We created our own webhook(s) in the Bitbucket repository for PR events like pullrequest:merged. When a webhook is triggered, it sends a notification to a webserver that we have running on an existing Azure VM. The event payload is parsed, and a build request is sent to our our Azure DevOps build server, using the Azure DevOps REST API. This is the solution we're going with.

Either workaround adds another machine to the process flow, but that can't be avoided.

0 votes
Ray Depew January 21, 2022

(Three years later)

There is a way to do this now, but it's still not perfect.

See the "PR triggers" section of this document: https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/bitbucket?view=azure-devops&tabs=yaml#pr-triggers

Unfortunately, the PR trigger only works when a PR is created or updated, but not on the merge commit. The Azure documention reference above says:

Each new run builds the latest commit from the source branch of the pull request. This is different from how Azure Pipelines builds pull requests in other repositories (e.g., Azure Repos or GitHub), where it builds the merge commit. Unfortunately, Bitbucket does not expose information about the merge commit, which contains the merged code between the source and target branches of the pull request.

I'm searching the Atlassian Community right now for more information on that last sentence. (That's how I ran across this question.)

Ray Depew August 30, 2022

Another update.

Atlassian has created a Jira ticket for this issue, see BBCLOUD-20718.

It's still in status "Gathering Interest". Currently it only has 13 votes. If more users vote for it, perhaps Atlassian will give it more priority and work on it.

0 votes
davina
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 25, 2019

Hi @Karthik Kotha 

Currently there doesn't seem to be an existing plugin between Azure Pipelines and Bitbucket. There is one for Jira as you can see here.

You can however set up Bitbucket Pipelines in your Bitbucket repository to trigger Azure deployments on your PRs. We also have Bitbucket pipes which wrap up this functionality for you. Here are some docs you might find useful:

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events