Bitbucket cloud pull request merge check functionality doesn't work for commit build status updated through API

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

When the commit build status is updated through the API, the pull request merge check functionality, which checks the last commit for at least 1 successful build, no failed builds, and no in-progress builds, doesn't work as expected.

For example, if the last three commit statuses were successful, failed, and failed, the check should ideally pass since the latest one is successful. However, the current implementation checks for any failed build in the list, causing the merge check to fail ("The source branch has failed merge checks that need to be resolved.")

This behavior differs from Bitbucket Pipeline builds, where only the latest build status is considered to pass or fail the merge check. This needs to be implemented for commit build status updated via the API as well.

Solution

Use "Pull Request ID" for the API key parameter so that the build status will be always overwritten, instead of creating a new line item for each build status. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 API request body for "Create a build status for a commit" { "key": "PR-ID", "url": "https://jenkins.com", "state": "SUCCESSFUL", "name": "status-test-job-4" } eg: { "key": "3", "url": "https://jenkins.com", "state": "SUCCESSFUL", "name": "status-test-job-4" }

This way, if the latest build is successful, the merge check will pass.

Note:

In case you are using Bitbucket Build Status Notifier, make sure the buildKey parameter is set to use the pull request ID, as shown above.

Updated on March 5, 2025

Still need help?

The Atlassian Community is here for you.