Setting up Bitbucket Cloud integration at global level

How to set up Bitbucket Cloud and SonarQube Community Build for integration at the global level.

This section explains how to set up Bitbucket Cloud and SonarQube to allow users to import Bitbucket Cloud repositories. To perform this setup, you need the global Administer System permission in SonarQube.

To set up Bitbucket Cloud authentication in your SonarQube Community Build instance, see Bitbucket Cloud.

Prerequisites

You’ve set a SonarQube Community Build base URL in SonarQube Community Build: see Server base URL.

Step 1: Create your OAuth consumer

SonarQube uses a dedicated OAuth consumer to import repositories and display your quality gate status on pull requests. When you create your OAuth consumer, Bitbucket automatically creates an OAuth key and an OAuth secret that you will need in Step 2.

Proceed as follows:

  1. Create the OAuth consumer in your Bitbucket Cloud workspace settings and specify the following:

    • Name: The name of your OAuth consumer.

    • Callback URL: Bitbucket Cloud requires this field, but it’s not used by SonarQube so you can use any URL.

    • This is a private consumer: Your OAuth consumer needs to be private. Make sure this check box is selected.

    • Permissions: Grant Read access for the Pull requests permission.

  2. Retrieve the created OAuth secret and key in your Bitbucket Cloud workspace settings under OAuth consumers. If you want to enter the secret in SonarQube in encrypted format, you can encrypt this secret.

See Sensitive settings for more information about settings encryption.

Step 2: Create a Bitbucket Cloud configuration record

This integration is performed through a "Bitbucker Cloud Configuration" record, which is used in SonarQube to access the Bitbucket Cloud instance.

Starting in SonarQube Server's Enterprise edition, you can integrate SonarQube with multiple Bitbucket Cloud instances, each instance being accessed with a different Bitbucket Configuration.

To set up a Bitbucket Configuration in SonarQube:

  1. In the SonarQube UI, go to Administration > Configuration > General Settings > DevOps Platform Integrations.

  2. Select the Bitbucket tab and click Create configuration. The Create a configuration dialog opens.

  3. Select Bitbucket Cloud.

Select Bitbucket Cloud in the Create a configuration dialog.
  1. Specify the following settings:

    • Workspace ID: The workspace ID is part of your bitbucket cloud URL https://bitbucket.org/<workspace-id>/<repository-slug>

    • OAuth Key: The key you created in Step 1.

    • OAuth Secret: The secret you created in Step 1.

Importing Bitbucket Cloud repositories Adding analysis to Bitbucket pipeline Troubleshooting

Last updated

Was this helpful?