Sonar scanner pull request analysis not showing in Azure DevOps PR

Template for a good new topic, formatted with Markdown:

  • ALM used - Azure DevOps
  • CI system used - Azure DevOps
  • Scanner command used when applicable (private details masked)
steps:
  - task: Bash@3
    displayName: Execute Sonar Scanner CLI - pull request
    env:
      PROJECT_KEY: $(solutionName)
      SONAR_TOKEN: $(sonar_token)
      BRANCH: $(Build.SourceBranchName)
      PR_ID: $(System.PullRequest.PullRequestId)
      ORGANISATION: $(organisation)
    inputs:
      targetType: 'inline'
      script: |
        sonar-scanner -X -Dsonar.organization=$ORGANISATION -Dsonar.projectKey=$PROJECT_KEY -Dsonar.projectName=$PROJECT_KEY -Dsonar.pullrequest.key=$PR_ID -Dsonar.pullrequest.branch=$BRANCH -Dsonar.pullrequest.base=main
  • Languages of the repository - Go
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
  • Steps to reproduce
    I am executing the above sonar scanner task in my Azure DevOps pipeline, it executes and shows the Pull Request in Sonar Cloud, but it’s not decorating the PR with any issues that are raised in the analysis.

We have separate Dotnet project where we’re using the inbuild Sonar Cloud tasks and they work as expected, decorating the PR with issues and code coverage analysis.

Are there additional properties that I’m missing? Is there documentation around doing this, I can’t find any on PR’s with sonar scanner.

I got the quality gate analysis to fail the build (correct behavior) by including the following properties:

sonar.pullrequest.provider=*****
sonar.pullrequest.vsts.instanceUrl=https://dev.azure.com/*****/ 
sonar.pullrequest.vsts.project=*****
sonar.pullrequest.vsts.repository=*****