Setting up Bitbucket Cloud integration at global level
How to set up Bitbucket Cloud and SonarQube Server 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.
Prerequisites
You’ve set a SonarQube Server base URL in SonarQube Server: 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:
- 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. 
 
- 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.
To set up a Bitbucket Configuration in SonarQube:
- In the SonarQube UI, go to Administration > Configuration > General Settings > DevOps Platform Integrations. 
- Select the Bitbucket tab and click Create configuration. The Create a configuration dialog opens. 
- Select Bitbucket Cloud. 

- Specify the following settings: - Configuration Name (Enterprise and Data Center Edition only): The name used to identify your Bitbucket Cloud configuration at the project level. Use something succinct and easily recognizable. 
- 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. 
 
Related pages
Importing Bitbucket Cloud repositories Setting up Bitbucket Cloud integration for your project Adding analysis to Bitbucket pipeline Troubleshooting
Last updated
Was this helpful?

