Bitbucket pull request decoration help

  • ALM used: Bitbucket Cloud
  • CI system used: Jenkins
  • Scanner command used
    bat "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=$BRANCH_NAME -Dsonar.branch.target=develop"
  • sonar-project.properties file:
sonar.organization=xxxxxx
sonar.projectKey=xxxxxxxx
sonar.host.url=https://sonarcloud.io
sonar.sources=./src
sonar.python.version=3.6
  • Languages of the repository: Python

I’m not seeing the full pull request decoration in bitbucket, and I’m wondering what I’m doing wrong.
I see the code quality printout, and it correctly shows a few code smells that I intentionally added:

However, if I go to that code in the PR, I don’t see any sonarcloud banners surrounding the offending code:

If I go to sonarcloud.io, I can see the code smells there. But they’re not showing up in bitbucket.

I would expect to see something like this in bitbucket:
(https://www.sonarqube.org/atlassian-bitbucket-integration/index/helper-code@2x.png)

Ok I got it to work!

I had to run the following: (Python code)

            pull_request_id = f"-Dsonar.pullrequest.key={pull_request.id}"
            source_branch = f"-Dsonar.pullrequest.branch={pull_request.source}"
            target_branch = f"-Dsonar.pullrequest.base={pull_request.target}"

            os.system(f"{self.scanner_home}/bin/sonar-scanner {pull_request_id} {source_branch} {target_branch}")

I used the bitbucket cloud API to get the pull request ID and target branch:
https://atlassian-python-api.readthedocs.io/bitbucket.html#bitbucket-cloud

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.