Add Support For Bitbucket Build Status

Hey Guys, I couldn’t find anywhere if you support posting build status to the Bitbucket. I saw there is support for Github, it would great to have that feature for Bitbucket too. Thank you!

Hi @buildbot-gitl :wave:

It’s already supported, and works the exact same way as the GitHub status works:

  1. You have to connect your Bitbucket account to your account
  2. And make it the “service credential user” if it isn’t already

You can find a related debug guide/discussion here, written for GitHub, but works the exact same way for Bitbucket (and for GitLab) too:

If you’d have any questions just let us know! :wink:

1 Like

Hi Victor,

Thank you for really good guides you put together! They help quite a bit during the setup. I managed to get build status show up when PRs happen on the main repo, but whenever there is a pull request from a fork then bitbucket shows no build status on the PR. Do you know how I can get that working?

I already gave “service credential user” admin access to forks as well, hoping that will help with the issue, but unfortunately still can’t see statuses on those PRs.

Thank you,

Victor, I actually noticed that when system goes to perform a workflow, it grabs latest commit from the destination branch, not source branch. How can I fix that?

That’s by design. A PR build is a pre-merged build. The clone step in case of Bitbucket clones the destination, then applies a diff on it from the source, to simulate the code if/after the PR is merged. This is standard practice in pull request testing. If you don’t want this and would like to build just the source instead, then modify your trigger map to not to do pull request building: - related section with technical details about PR builds:

I believe that might be impossible, due to Bitbucket API limitations. This seems to be the related issue:

Technically you send the build status to a commit, not for a pull request. When you start a PR from a fork, the commit is not yet in the main repository, and so pushing the status to that commit for the main repository is not possible (you’ll get a 404 not found or similar response).

Might be wrong, but the issue seems to indicate this is the case.

Gotcha, I forgot that apply does not create commits. I saw that commits are different between “Commit hash” and $GIT_CLONE_COMMIT_HASH in the logs, and got confused.

I know what you mean, I thought exactly the same. That’s why I added “service user” to the fork thinking that it would help.

Thank you for your help.

1 Like

The issue with this is due to the limitations of the Bitbucket build status API we could only send status into forks in which the specified user (e.g. the “service user”) has the necessary access rights. E.g. if a colleague of yours would fork the repo and send a PR the status could not be sent there until the “service user” is granted access to the fork. PRs from the same repo can get the build status indicators because in that case the commit is part of the same repo / can be accessed with the same credentials.

I’d suggest you to upvote the related feature request on the Bitbucket tracker, the one I linked above.

Sounds good, thank you very much for all your answers. I did upvote that feature, seems to be not very popular though…

AS a workaround we decided to implement an extra step in the workflows that posts a build status as comment on the PR.

1 Like

Sounds like a good solution if your use case can be handled by the existing Bitbucket status API.

Note: if you’d need some help or would want to create a custom step for this, you can check our GitHub Status reporter step, to use it as a base template for your own step:

(in case of this step is not required for PR fork checks as does support sending commit status into the destination repo for fork based PRs; this step is mainly useful for self hosted GitHub servers, but the structure should be sufficient for a status sender step)

@viktorbenei but does the service user work for a self hosted bitbucket installation? Cause I keep getting the error

Error: No API integration for git hosting service yet. For more information check out this guide.

Where do you get that @AlexandruB?

And even more important @AlexandruB, are you talking about the hosted solution, or Bitbucket Server which is the on-premise solution?

OK, just read your question again @AlexandruB - you’re referring to the self-hosted / on-premise Bitbucket Server.

That’s a completely separate system, with its own API, and so the connected service user (which is a connection) can not be used for that as it’s incompatible ( and the on-premise Bitbucket Server - formerly Stash - don’t have the same API, there are completely separate services with incompatible APIs).

For the on-premise / self hosted Bitbucket Server please see the related #feature-request and discussion at: