Get build results for a pull request in a merge check

I’m working on a merge check plugin, based on this tutorial, that should approve or reject the merge based on the build results.

There is documentation on how to get and change build results for a commit using the REST API. How can I get the build results from within a plugin?

Since I know build results are specific to a commit, I thought I might be able to get the information from PullRequestMergeHookRequest#getFromRef() but I’m not able to find any route from there to a build result.

I haven’t been able to find any hints on working with build results at all in this forum or in the javadoc. I even poked around for class names in the UI that might give clues. Everything I can find on google relates to reporting results from third parties, not getting results internally, or build results in Bamboo rather than Bitbucket. (The results might come from Bamboo, sure, but they can also come from other places.)

Any pointers? Thanks.

To answer my own question, it’s all in

The docs at some point directed me to a quite old version of the APIs, and the example plugins themselves are also build on Bitbucket 5, which is why I couldn’t find it. For such old versions (before 7.4.0), I need to include the build API explicitly as a new dependency:


which I found documented for my version of Bitbucket (6.3.2) here.

Newer versions have this included in the core API, though the interface used in v6 was deprecated and will be removed in v8.

And even though it’s been deprecated, the code to wire in the build status service so you can look up build results looks like:

public class MyMergeCheck implements RepositoryMergeCheck {
    private final BuildStatusService buildStatusService;

    public MyMergeCheck(@ComponentImport BuildStatusService buildStatusService) {
        this.buildStatusService = buildStatusService;