Bitbucket Cloud

With a bound project, SonarQube Cloud offers numerous analysis reporting features that are supported in Bitbucket Cloud. This page explains how to set them up.

Once your Bitbucket Cloud workspace has been imported to SonarQube Cloud, you can create your SonarQube Cloud project by importing your Bitbucket Cloud repository. The created SonarQube Cloud project is bound to its Bitbucket Cloud repository, see Binding with the DevOps platform for more details. To bind an unbound project, see Binding an unbound project to a repository.

Setting up pull request integration

For a bound project, the quality gate status and analysis metrics are reported to your pull requests in Bitbucket Cloud provided:

  • Your build script is configured to build on pull request creation and push.

  • If you don't use an integrated CI tool, you must set up the pull request parameters manually, see Pull request analysis for more details.

  • See Prerequisites for CI-based analysis for additional information.

The status of your SonarQube Cloud project's quality gate can be displayed in the Bitbucket Cloud quality gate widget.
Preventing the pull request merge if the quality gate fails

If you use Bitbucket Pipelines, see Bitbucket Pipelines for more details. Otherwise, proceed as described below.

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 PR after the analysis results are available.

Define the number of builds to pass in Bitbucket Cloud before allowing pull requests to pass your SonarQube Cloud quality gate.

You can set the Minimum number of successful builds for the last commit with no failed builds and no in progress in Bitbucket, to the number of builds that run for the pull request.

The blocking of pull requests on quality gate failure is not supported for projects on a monorepo.

Reporting analysis metrics in the Bitbucket repository overview

For a bound project, the analysis metrics of the main branch are reported in the Bitbucket repository overview, see Viewing the issues detected on a pull request for more information. To enable this feature, you must enable the Repository Overview widget.

Screenshot of the Bitbucket interface with the SonarQube Cloud project analysis results widget.
Enabling the Repository Overview Widget
  1. In Bitbucket Cloud, retrieve your project.

  2. Go to Your Repository > Repository settings > SonarQube Cloud > Settings.

  3. Select Show repository overview widget.

There is a checkbox in the Bitbucket interface that will enable the analysis overview widget coming from SonarQube Cloud.
  • If you don’t see the widget with quality information, make sure that your browser is not using some extensions like AdBlocks. They tend to break the integration of third-party applications in Bitbucket Cloud.

  • The Repository Overview always shows the status for the master branch, even if you select another branch. This is a limitation of the current integration with Bitbucket.

Last updated

Was this helpful?