Configuring Bitbucket Cloud project binding
How to set up Bibucket Cloud integration features for your SonarQube Server project.
Was this helpful?
How to set up Bibucket Cloud integration features for your SonarQube Server project.
On SonarQube Server projects bound to their Bitbucket Cloud repository, SonarQube Server automatically sets up the report of your quality gate status and analysis metrics directly to your pull requests.
You can bind an existing and manually created project to its Bitbucket Cloud repository provided the global integration of SonarQube Server with Bitbucket Cloud has been properly set up. To do so, see Changing your project binding.
After setting up a pull request analysis, you can block pull requests from being merged if it is failing the quality gate. To do so, you configure a branch restriction. The set up is different whether you use Bitbucket Pipelines or not.
You need the Premium Bitbucket Cloud plan.
Preventing pull request merges when the quality gate fails is not supported for monorepos.
You must make sure that the Bitbucket Pipeline fails when the quality gate fails. See Failing the pipeline job when the quality gate fails.
Configure a branch restriction as follows:
In Bitbucket, go to Repository settings > Branch restrictions to either Add a branch restriction or edit your existing one.
In the Merge settings tab:
Set Minimum number of successful builds for the last commit with no failed builds and no in progress builds to 1.
Select the Prevent a merge with unresolved merge checks option.

If you know how many builds you have for a pull request, you can run your SonarQube Server analysis and not block the pipeline waiting for results. The SonarQube Server Quality Gate will appear in the build for your pull request after the analysis results are available.
Configure a branch restriction as follows:
In Bitbucket, go to Repository settings > Branch restrictions to either Add a branch restriction or edit your existing one.
In the Merge settings tab, set Minimum number of successful builds for the last commit with no failed builds and no in progress builds to the number of builds that run for the pull request. The figure below shows an example with 2 builds.

Binding to Bitbucket Cloud Importing your Bitbucket Cloud repository Bitbucket Pipelines
Was this helpful?
Was this helpful?

