SonarCloud analysis not showing in Bitbucket pull request

I have a project in Sonar Cloud that is linked to my Bitbucket repository. I can see analysis in the source view within Bitbucket. The analysis completed in Sonar Cloud for the branch with the open pull request. When a pull request is opened, the “Code Quality” block is empty. My organization just migrated over to cloud a few weeks ago and this doesn’t appear to be working on any pull requests across many repositories. After adding pull request pipelines into the bitbucket pipelines file I do see the analysis report in the right menu under “Reports” but still nothing in the Code Quality block.

We’re injecting the properties for use by the Gradle plugin like this and then using the sonarqube task to perform the analysis.

sonarqube {
    properties {
        property "sonar.projectName", "${project.name}"
        property "sonar.projectKey", "${group}:${project.name}"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.host.url", "${sonar_host}"
        property "sonar.login", "${sonar_username}"
        property "sonar.organization", "${sonar_org}"
    }
}
  • ALM: Bitbucket Cloud
  • CI: Bitbucket Cloud
  • Scanner: Gradle plugin
  • Language: Java

Hi @burlesgonewild,

Apologies for the late reply and welcome to the community! Let me reiterate so I can understand better what is going on.

You run the analysis in the Bitbucket Pipeline using the gradle task and it finishes with the success?
You do not see that pull request in the SonarCloud UI?

If you are analysing PRs with the given properties I think you are missing sonar.pullrequest.key.

Best,
Marcin

I’ve set the following in my Gradle file and am now getting errors when I view the pull request in Sonarcloud. I’m populating the variables in my pipeline build.

properties {
        property "sonar.projectName", "${project.name}"
        property "sonar.projectKey", "${group}:${project.name}"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.host.url", "${sonar_host}"
        property "sonar.login", "${sonar_username}"
        property "sonar.organization", "${sonar_org}"
        property "sonar.pullrequest.key", (project.hasProperty("sonar_pr_key")) ? "${sonar_pr_key}" : ""
        property "sonar.pullrequest.branch", "${sonar_branch}"
        property "sonar.pullrequest.provider", "bitbucketcloud"
}

Pull request decoration did not happen. Configuration missing to decorate the Bitbucket Cloud pull request: BitbucketCloudPrConfiguration{owner=null, repository=null, id=186, headSha='eb92e327cfb1', triggerCommitSha=null}

Looks like I’m still missing some configuration. I would expect the integration to populate this information from the Bitbucket environment variables instead of having to set this up manually. What else am I missing?

Hi @burlesgonewild,

These properties that are missing:

  • sonar.pullrequest.bitbucketcloud.owner
  • sonar.pullrequest.bitbucketcloud.repository

indeed should be autodetected if run in the BitBucket Pipelines (based on the fact that BITBUCKET_PR_ID is present in the environment).

Can you share with me the logs of the analysis (preferably if you set sonar.verbose=true property) with the first config you provided (the one without sonar.pullrequest.key)? I opened the private thread for that.

Best,
Marcin