Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Why is the required builds merge check still failing after a successful build?


I am attempting to configure the required builds merge check on Bitbucket Server to meet the following requirements:

  1. Prevent merging PRs until one specific Jenkins job succeeds on the latest commit of the PR.
    • Note: this requirement could be relaxed to "until any Jenkins job succeeds" instead of requiring a specific job to pass, but it would be ideal to require a specific job.
  2. Do not prevent merging PRs if any other Jenkins job(s) fail on the same commit.

I was originally using the minimum successful builds merge check, but that does not meet requirement #2 because it prevents merging PRs if any failed builds appear (even if there is also 1 successful build).

The required builds merge check configuration is not working as I expected. It seems to fail to recognize a successful build regardless of what build key I specify.

I set up a simplified test to confirm what I was seeing with these steps:

  1. Create a new repo to test
  2. Make an initial commit on the "main" branch
  3. Create a branch "test" and make a single commit on the "test" branch
    • The commit ID was 7eceb4d213a211c86499e708a05efae644a867e3
  4. Open a PR with source branch "test" and target branch "main"
    • Confirmed the PR was ready to merge (no merge check issues)
  5. Configure a required build for key "testKey":
    required builds config.png
    • Confirmed the PR merge is blocked due to missing required build:
      blocked merge 1.png
  6. Add a successful build to the latest commit via the REST API:
    •  § curl --location --request POST 'https://<redacted>/rest/build-status/latest/commits/7eceb4d213a211c86499e708a05efae644a867e3' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Basic <redacted>' \
      --header 'Cookie: BITBUCKETSESSIONID=<redacted>' \
      --data-raw '{
      "state": "SUCCESSFUL",
      "key": "testKey",
      "name": "testName",
      "url": "",
      "description": "testDescription"
  7. ❌ The PR merge was still blocked due to missing required build:

    blocked merge 2.png
    • My expectation was that the required build merge check would pass after posting the successful build result with key "testKey".
    • Confirmed the build with key "testKey" is listed as expected via the REST API:
      •  % curl --location --request GET 'https://<redacted>/rest/build-status/latest/commits/7eceb4d213a211c86499e708a05efae644a867e3' \
        --header 'Accept: application/json' \
        --header 'Authorization: Basic <redacted>' \
        --header 'Cookie: BITBUCKETSESSIONID=<redacted>'


What is missing from this test to allow the required builds merge check to pass? I'm hoping that a resolution to this simple example will help me find the issue when attempting similar config on my real repo.

1 answer

1 accepted

I got an answer from Atlassian support on this so I'm sharing it here in case it helps someone finding this question later.

My testing was using a deprecated API to report the build status, deprecated in Bitbucket 7.14: 

In Bitbucket 7.14, the following new REST end-points are added for build-status:

GET /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/builds
DELETE /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/builds

The following REST end-points are deprecated:

GET /rest/api/1.0/build-status/latest/commits/{commitId}
POST /rest/api/1.0/build-status/latest/commits/{commitId}

Using the new API worked as expected and allowed the required builds merge check to pass. Here's the example request that the support representative used to test it:

curl -u admin:"the password" --location --request POST 'https://<url>/rest/api/1.0/projects/~admin/repos/tr/commits/c558c598cb74376ecff6347fe2c3dedae8eaba01/builds' \
--header 'Content-Type: application/json' \
--data-raw '{"key":"testKeyCF1","state":"SUCCESSFUL","url":"https://bamboo.url/browse/TEST-REP1-3","buildNumber":"1","description":"Unit test build","duration":1500000,"lastUpdated":1359075920,"name":"Database Matrix Tests","parent":"testKeyCF","ref":"refs/heads/testcfb","testResults":{"failed":0,"skipped":0,"successful":1}}'

And some important details shared about the data:

  1. The "parent":"testKeyCF" is correlated with the "key":"testKeyCF1". It's important to make sure the parent and key correlate.
  2. The key should have an incrementing number after
  3. The "ref":"refs/heads/testcfb" should point to the correct branch

I also confirmed that the Bitbucket Branch Source plugin used with Jenkins to report build status in real use cases (as opposed to my testing using curl) also uses the deprecated API. This explains why the required builds merge check was not working in real use cases as well. 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events