Add Bitbucket Server build status to pull request decoration

I am using SonarQube Developer Edition 7.9 and latest Bitbucket Server 6.6.1 with Branch Analysis and PR decoration enabled. This reports violations fine but I can’t find a way do prevent user from merging a PR with a failed Quality Gate.

SonarQube uses the CodeInsight API to post a report to Bitbucket. As per Bitbucket documentation, a failed report does not prevent a merge: https://developer.atlassian.com/server/bitbucket/how-tos/code-insights/ at the bottom.

Posting a failed report will not stop a pull request from being merged. There are build status settings that can be set up for a repository or project that will block the merge so it is recommended to also post a failed build status if wanting a report to affect the mergability of a pull request.

I suggest to add a configurable option to also push a success/failed build status to Bitbucket Server when a quality gate succeeded/failed for a PR analysis. This way the build status merge check can be used to prevent merging of a PR when the quality gate failed.

Thats all working with the https://plugins.jenkins.io/cloudbees-bitbucket-branch-source for jenkins. Which CI do you use?

Same issue as described by Peter above. We’re using the latest version of SonarQube/Bitbucket Server 6.6.1/cloudbees-bitbucket-branch-source.

The report comes back as failed, but the dev can still merge. And I don’t see a place to modify this behavior, or enforce a merge check due to failed SQ state.

@reitzmichnicht I am using Jenkins and I understand that I can prevent the merge If I fail the build in Jenkins.
But what if I want to have just the Sonar Quality Gate fail and not the Jenkins build, then I would need a separate Build status reported in Bitbucket from Sonar for that failed Quality Gate tied to the Commit ID.

It’s enough to set the jenkins build to unstable on failed sonar quality gate. This will be transferred as failed to the bitbucket build status and prevent merges.