Block Merge via Merge Check in PR (SonarQube/BitBucket)


I searched for an answer to this prior to posting, but didn’t find anything specific about requirements to set up Merge Checks or Blocking-Merge on Failed Sonarqube Quality Gate.

We have set up PR decorations with Bitbucket Server and Sonarqube Dev Edition instance, but are not seeing an immediate way to set up a Merge Check to block devs from merging if the SQ Quality Gate fails after analysis. We see the Sonarqube report just fine in the PR, but in Bitbucket, there is no Merge Check that is linked to SonarQube so they can still merge.

Do we need to install the Sonar from Bitbucket plugin or similar to get this functionality? We do not want to fail the build based on the quality, but rather introduce a block as we would in the event of Jenkins build failures, etc.

Atlassian Bitbucket Server v6.6.1 (on-prem)
SonarQube Developer Edition Version 7.9.1 (build 27448) (on-prem)

We do not currently have any Sonar plugins installed on the bitbucket side. I saw Sonar for Bitbucket as a plugin in Bitbucket’s marketplace, but wanted to confirm this was what we were missing before downloading it. If so, is it an additional cost on top of our Sonarqube license?



1 Like

Hi @jcarverextnsis,

Welcome to our community forum, and sorry for the late answer.

With the 6.9 version of BitBucket Server that Atlassian just released, it is now possible to block the merge of a PR decorated with SonarQube if the quality gate is red.

To enable it, as soon as you decorate PR with SonarQube, you just need to go to your project settings in Bitbucket Server -> Code Insights and add a requirement for the report com.sonarsource.sonarqube like this for example :

And in your PR, you should see something like this:

We plan to update the documentation to make that clear.

Hope it helps!


Thanks so much for the reply. I’ll take this to my team!



1 Like