Pull Request on merge commit not supported for Bitbucket Cloud and Azure Pipelines?

Ray Depew
Contributor
January 27, 2022

Our project repository is on Bitbucket Cloud. We are building using Azure Pipelines. Our triggers in the pipeline are set up in this fashion:

trigger:
- '*'
pr:
- develop
- develop/*
- master/*
- feature/*
- release_*

CI builds are triggered on every commit, as expected. PR builds are triggered when PRs are created or updated, but not when merged. We note that this is expected behavior for Bitbucket Cloud, per the Azure Devops documentation (emphasis is mine):

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.

That is, a PR build is triggered when a PR is created or updated, but not on a merge commit.

That is indeed unfortunate. To correct this deficiency requires some cooperation between Microsoft and Atlassian. Is either party working on a solution? If not, is there a kludge or workaround we can use instead?

EDITED TO ADD: This is not intended as a flame or a complaint. BB Cloud is great. I'm just trying to find a way to make this work.

3 answers

1 accepted

0 votes
Answer accepted
Ray Depew
Contributor
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
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 1, 2022

Hi @Ray Depew ,

We have a feature request about this in our issue tracker:

If you're interested in that feature, I would suggest adding your vote there (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features. You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

Implementation of new features is done as per our policy here and any updates will be posted in the feature request.

Kind regards,
Theodora

Ray Depew
Contributor
February 7, 2022

Hi @Theodora Boudale , thank you for the tip. 

I added my vote to the Jira issue. With only six votes in 13 months, it might be a while before anybody gets around to it. (Insert smiley here, as appropriate.)

Just an observation: from the number of votes for the Jira issue, I infer that the number of SW Dev groups using Bitbucket Cloud in connection with Azure Pipelines is is a small number. Like 6, maybe?

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2022

Hi Ray,

I don't have any info on the number of software development teams that use Bitbucket Cloud with Azure Pipelines, but I don't think that the number of votes in the feature request is indicative of that.

There may be teams using the integration that don't have that requirement for their builds. There may also be teams with that requirement that find another way to work around this issue (like with Ankit's suggestion) and/or may never contact Bitbucket Cloud support about this, so they may not be aware of the feature request.

0 votes
Ankit Gupta January 27, 2022

Hey Ray,

I haven't used Azure Pipelines, but looking at the documentation, can't you use the branches trigger? That would run whenever the PR gets merged.

Or is there some other use case you would like to solve with PR merged?

Ray Depew
Contributor
January 31, 2022

Yes, that's one option we're looking at.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events