Start FreeLog in
SonarCloud | Getting started with SonarCloud | Analyzing Bitbucket Cloud projects

Getting started with Bitbucket Cloud

On this page

If your code is on Bitbucket Cloud, go to the SonarCloud product page and choose Set up or Login, then select Bitbucket from the list of DevOps cloud platforms.

You will be taken to the Bitbucket login page. Sign in using your Bitbucket credentials.

Welcome to SonarCloud

Once you have successfully logged in, you will see the SonarCloud welcome screen.

Select Import projects from Bitbucket.

Welcome to SonarCloud for the first time.

Set up your organization

Connect your Bitbucket Cloud workspace to SonarCloud

When prompted, grant access to the SonarCloud application to read your Bitbucket Cloud workspace. SonarCloud requests access for:

  • reading your account information.
  • reading your repositories and their pull requests.
  • reading your team membership information.

Create your SonarCloud organization

SonarCloud is set up to mirror the way that code is organized in Bitbucket Cloud (and other repository providers):

  • Each SonarCloud project corresponds one-to-one with a Bitbucket project, which resides in its own Git repository.
  • Bitbucket projects are grouped into Bitbucket workspaces.
  • Each SonarCloud organization corresponds one-to-one with a Bitbucket workspace.

In this step, you will create a SonarCloud organization that corresponds to your Bitbucket workspace.

SonarCloud will suggest a key for your SonarCloud organization. This is a name unique across all organizations within SonarCloud. You can accept the suggestion or change it manually. The interface will prevent you from changing it to an already existing key.

Choose a plan

Next, you will be asked to choose a SonarCloud subscription plan. If all the repositories to be analyzed are public on GitHub, you can select the free plan. When using the free plan, your code and analysis results will be publicly accessible at sonarcloud.io/explore/projects.

If you want to analyze one or more private repositories then you need to select the Team or Enterprise plan. Monthly plans offer a 14-day free trial period. Once the 14 days have elapsed, the cost is based on the number of lines of code analyzed. For more information, see Managing your subscription.

Once you have chosen a plan and clicked Create Organization, your SonarCloud organization will be created!

Set up your analysis

Import repositories

The next step is to import the projects (that is, individual Git repositories) that you want to analyze from your Bitbucket workspace into your newly created SonarCloud organization. A corresponding SonarCloud project will be created for each.

SonarCloud will present a list of the repositories in your Bitbucket workspace. The selected projects will be imported.

Choose the Bitbucket repositories you want to import into SonarCloud.

Choose your new code definition

The next step is to set the New Code Definition (NCD) for your project(s). The NCD is a mandatory step and it defines which part of your code is considered new code. This helps you to focus your attention on the most recent changes to your code and allows you to follow the Clean as You Code methodology.

For more information, check out the About new code page. 

Configure analysis

With Bitbucket Cloud projects, the actual analysis is performed in your build environment (cloud CI, local machine, etc.). This means you have to configure your build process to perform the analysis on each build and communicate the results up to SonarCloud.

SonarCloud will guide you through a tutorial on how to set up your build environment to perform analysis.

The first step is to select your build environment. SonarCloud will present this page:

Choose your preferred CI tool as the SonarCloud analysis method.

If you have no particular preference and are setting up a new project on Bitbucket Cloud, we recommend using Bitbucket Pipelines as your CI.

Follow the in-product tutorial to correctly set up your analysis.

See your analysis results

Once it is complete, you can view the results of your first analysis. SonarCloud also displays some result data directly in the Bitbucket cloud interface itself. 

In addition, please see the page on Bitbucket Pipelines to integrate SonarCloud into your Bitbucket pipeline. 


Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License