PR decoration in Azure DevOps not working

  • ALM used: Azure DevOps
  • CI system used Azure DevOps
  • Languages of the repository: mainly C#/.NET

Hi, I’m currently trying to integrate SonarCloud into our Azure DevOps project. So far, I have a working YAML pipeline which runs in my test pull request and analyzes the code. This is working and I also see the PR with the analysis result in SonarCloud.
What doesn’t work is the PR decoration. The SonarCloud Azure DevOps PAT has the Code read/write permissions and we can see the PR when logging in with that user so that shouldn’t be the issue. There are also no errors in the pipeline.
From my understanding, SonarCloud should always add a comment to the PR, even when there are no code changes, is that correct? I’m asking because that PR doesn’t have any code changes, it only adds the YAML pipeline to the repository.

These are the SonarCloud tasks we’re using in the pipeline:

  ...
  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'SonarCloud (build)'
      organization: 'xxx'
      scannerMode: 'MSBuild'
      projectKey: 'xxx'
      projectName: 'xxx'
  - task: VSBuild@1
    ...
  - task: VSTest@2
    ...
  - task: SonarCloudAnalyze@1
    displayName: 'Run Code Analysis'
  - task: SonarCloudPublish@1
    displayName: 'Publish Quality Gate Result'
  ...

Any hints are appreciated.

No, for Azure DevOps a comment will only be added if there is an issue.

And, for a PR, there should be a status check that is populated if everything works properly. See the branch and pull request section of the docs for the SonarCloud Azure DevOps extension.

Do you see a SonarCloud status check on the Pull Request where analysis has run?

Hi Colin, thanks for the quick reply!

No, for Azure DevOps a comment will only be added if there is an issue.

Good to know, that explains why we don’t see a comment :smile: We’ll merge the PR and see if SC reports errors on other PRs then :slightly_smiling_face:

Do you see a SonarCloud status check on the Pull Request where analysis has run?

Yes, there is a passed quality gate check on the PR. Seems like it’s working as expected then!

1 Like

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