Bitbucket Cloud Pull Request Analysis

Hi there,

I’ve setup SonarCloud on our Bitbucket Cloud instance and it’s working well on the branches. On our repository pull requests, the Sonar plugin displays “Not analyzed on SonarCloud yet”.

I’ve configured the Sonar analysis on the default pipeline as follows:

- step:
     - maven
     - docker
     - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar \
        -Dsonar.projectKey=myproject -Dsonar.pullrequest.bitbucketcloud.repository=myrepo \
        -Dsonar.pullrequest.bitbucketcloud.owner=myorg -Dsonar.organization=myorg -Dsonar.login=$SONAR_TOKEN
     - docker

What else do I need to do to get the pull request analysis working?


I also added an equivalent build step for default pull-request build. But it looks like these don’t run in Bitbucket if the pull request originated from a fork? Is there another way to make SonarCloud analyse pull requests?

edit 2:

Looks like the pull-request analysis is done after merging :expressionless:



Hi Paul,

Bitbucket Pipelines recently added support for triggering builds on PR. It was not the case before and we had to find a trick to make things work at best. Looks like this trick is not working well anymore now that they’ve deployed their support for builds on PR :frowning: We plan to work on a fix in the upcoming 2 weeks to rely on this new feature and make your PR analyzed again.

Oh, and just a little comment on your pipeline YML file. You don’t need to pass the 2 following properties, SonarCloud automatically guesses them for you when your build is executed on Bitbucket Pipelines: