Zukky
(Zukky Baig)
December 14, 2021, 4:10pm
1
Hi,
I am trying to configure pull request analysis on SonarCloud. Our SCM provider is Bitbucket Cloud. I have set the “sonar.pullrequest.provider” in the Administration → General Settings → Pull Requests to “BitbucketCloud”:
Yet, when I open a Pull Request in Bitbucket, I still see this:
What am I doing wrong? Thank you.
Colin
(Colin)
December 14, 2021, 4:17pm
2
Hey there.
Bitbucket Cloud does not support Automatic Analysis – meaning there’s some configuration you need to do before you start seeing things analyzed.
Please reset the value you configured for Pull Request Provider
Follow the instructions in the UI, and make sure your pipeline runs on each pull request
The documentation on Getting started with Bitbucket Cloud is always helpful.
Zukky
(Zukky Baig)
December 14, 2021, 5:27pm
3
That assumes you are using Bitbucket pipelines right? I am using Bitbucket Cloud and TeamCity for our CICD process. Also, I have setup the analysis for our branches, which is working correctly through TeamCity, however, just this final hurdle of getting the Pull Request Analysis to work.
1 Like
Colin
(Colin)
December 15, 2021, 1:29pm
5
Hey there.
This is a community forum – please don’t bump threads (and certainly not less than a day later).
If you are using TeamCity, keeping in mind they do have a homegrown SonarQube integration that may work for SonarCloud (I haven’t tested it though), you will need to pass the sonar.pullrequest.*
parameters whenever a Pull Request is being raised (using environment variables that are available in your build environment ). Those sonar.pullrequest.*
parameters are define here
You’ll find similar advice for another CI (buildkite) here:
Thanks, Colin
Writing if condition by the building target worked!
if $BUILDKITE_PULL_REQUEST; then
/opt/sonar-scanner/bin/sonar-scanner -Dsonar.login=$SONARCLOUD_TOKEN -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.key=$BUILDKITE_PULL_REQUEST
else
/opt/sonar-scanner/bin/sonar-scanner -Dsonar.login=$SONARCLOUD_TOKEN -Dsonar.pullrequest.provider=GitHub -Dsonar.branch.name=$BUILDKITE_BRANCH
fi