Configuration for pull request decoration (Bitbucket)

Hey.

I implemented SonarCloud in our build process recently. I got a stable configuration for SonarCloud which works fine so far.

For scanning, I use the parameters sonar.projectKey, sonar.organization, sonar.host.url, sonar.branch.name, sonar.branch.target and sonar.login.
SonarCloud scans every built branch and even shows the results in the related pull request (we are using Bitbucket). Whats missing now are comments by sonar inside the pull request, telling the developer what he has to improve. For this, I included the following parameters to the scanning process: sonar.pullrequest.branch, sonar.pullrequest.base, sonar.pullrequest.provider, sonar.pullrequest.bitbucketcloud.owner, sonar.pullrequest.bitbucketcloud.repository, sonar.pullrequest.key. I also removed the params sonar.branch.name, sonar.branch.target since they seem to be in conflict with the other parameters.
After the scanning process is finished, SonarCloud shows that there was a problem with scanning. After googling I found out, that there seems to be a problem with owner and repository, since it required the related UUIDs and not the clear names.

I found the owner UUID by using
curl https://api.bitbucket.org/2.0/teams/teamname
I can’t get the repository UUID by using
curl https://api.bitbucket.org/2.0/repositories/teamname/repositoryname
since access is forbidden.

How do I get the UUID of that project? Do I need to authenticate with OAuth?

Another question is, is it possible make a merge check for Bitbucket? E.g. pull request does not match SonarClouds quality gates, so it can not be merged into target branch?

Best regards,
Ben

Hi Ben, which CI service are you using to trigger the analysis on your Bitbucket Cloud repositories?

Hi Fabrice,

I’m using Jenkins to trigger the analysis.

Hi Ben,
You are using the correct endpoints to fetch the UUIDs but your repository requires authentication for getting the configuration. You’ll have to authenticate for the second endpoint to return the UUID.

Another question is, is it possible make a merge check for Bitbucket? E.g. pull request does not match SonarClouds quality gates, so it can not be merged into target branch?

Bitbucket Cloud supports merge checks on Premium plan (https://confluence.atlassian.com/bitbucket/suggest-or-require-checks-before-a-merge-856691474.html) so I think what you want should be possible since SonarCloud pull request decoration marks the build as failed if the quality gate check fails.