A regular analysis is required before a branch analysis

Hello Everyone.

I am using a bitbucket cloud and using pipeline feature to kickoff a sonar cloud.

Here is what I have completed

  • Created a working repo with code already merged into the “master”.
  • Created a pipeline (bitbucket-pipelines.yml)
  • Configured the project in the sonar cloud, and noted the project token TOKEN_1
  • Linked the project to the bitbucket.
  • Update bitbucket-pipelines.yml with the following detail
mvn -B clean verify sonar:sonar -Dsonar.host.url=https://sonarcloud.io \
            -Dsonar.projectKey=PROJECT-KEY \
            -Dsonar.organization=PROJECT-ORG \

Project builds and compiles without any problem, however it fails due to -
Project was never analyzed. A regular analysis is required before a branch analysis.

When I checkout the project locally and run the above maven command, it works and I can see the results posted in the sonarcloud.io under the organization.

I am not sure why it fails when it is executed as part of the pipeline. Any thoughts, on what I did wrong?

Thanks in advance.


The error message indicates that:

  • A branch or pull request is being analyzed
  • The main branch of that organization/project key hasn’t been analyzed yet on SonarCloud

So if you ran the analysis locally, I assume that you analyzed the main branch so it exists now on SonarCloud. I would try again to analyze it on bitbucket - even it is a branch, it should now work.

Let us know if that’s not the case.