PR decorations not working for Azure Devops using yml pipeline

Hello as the title says I have issues with PR decorations, the repo is private so i cannot provide url to the PR.

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Languages of the repository (C#)
  • Error observed (no errors observed in any of the tasks prepare,analyze, publish)

Analyzing works well and i can see the comments i expect in the sonarcloud web interface however there is nothing showing in the PR in Azure devops. I have followed this guide as well. Below you can see my yml file, again i do not see any errors in the logs and it analyzes in sonarcloud. My only issue is not getting PR decorations. If you see below I added a script to confirm the properties in SonarPrepare task in my yml and the are correct. I am thinking that perhaps i am missing a property? Not sure what could be the problem,

Here is the ID to the backround task of the PR: AY4aN8fVWFdul8R5I0S_

Here is the yml i am using.

  - task: JavaToolInstaller@0
    displayName: 'Use Java 21'
      versionSpec: 21
      jdkArchitectureOption: 'x64'
      jdkSourceOption: 'LocalDirectory'
      jdkFile: 'C:\Users\BuildAgent\Downloads\'
      jdkDestinationDirectory: 'C:\java\runtime'
      cleanDestinationDirectory: true

  - checkout: self
    fetchDepth: 0

  - task: NuGetAuthenticate@1 
    displayName: 'NuGet Authenticate' 

  - task: UseDotNet@2
    displayName: 'Use .NET Core SDK 6.0.x'
      version: '6.0.x'

  - task: NuGetToolInstaller@1
      versionSpec: '6.9.1'
      checkLatest: true

  - task: DotNetCoreCLI@2
    displayName: 'NuGet restore'
      command: 'restore'
      feedsToUse: 'config'
      nugetConfigPath: 'nuget.config'

  - script: |
      echo "Pull Request ID: $(System.PullRequest.PullRequestId)"
      echo "Source Branch: $(System.PullRequest.SourceBranch)"
      echo "Target Branch: $(System.PullRequest.TargetBranch)"
    displayName: 'Print Azure DevOps Variables' 

  - task: SonarCloudPrepare@1
    displayName: 'Prepare analysis on SonarCloud'
      organization: $(SONAR_ORGANIZATION)
      scannerMode: MSBuild
      configMode: manual
      ProjectKey: $(SONAR_PROJECT_KEY)
      ProjectName: $(SONAR_PROJECT_NAME)
      extraProperties: sonar.scanner.msbuild.version=6.2.0
      Sources: '.'
      sonarScannerVersionChoice: 'latest'
      sonar.pullrequest.key: '$(System.PullRequest.PullRequestId)'
      sonar.pullrequest.branch: '$(System.PullRequest.SourceBranch)'
      sonar.pullrequest.base: '$(System.PullRequest.TargetBranch)'
  - task: DotNetCoreCLI@2
    displayName: 'Build the project - $(BUILD_CONFIG)'
        command: 'build'
        arguments: '--no-restore --configuration $(BUILD_CONFIG) /p:logFileVerbosity=detailed'
        projects: '**/*.csproj'
  - task: SonarCloudAnalyze@1
  - task: DotNetCoreCLI@2
    displayName: 'Code Coverage from Tests project'
      command: 'test'
      projects: 'Tests/**/*.csproj'
      arguments: '--collect "Code Coverage"'
  - task: SonarCloudPublish@1
    displayName: 'Publish Quality Gate Report on SonarCloud'
    continueOnError: true
      pollingTimeoutSec: '300'

Appreciate any help


Welcome to the community!

That guide that you followed looks like it might have(?) some age on it. Nonetheless, it seems essentially sound. I just want to verify that you did import the project into SonarCloud via the SonarCloud UI / wizard.


Hello! Thank you for the reply. I have solved the issue. And I think there is a bug in the process?
Let me explain, there are two things to consider:

  1. I missed adding the status check “Sonarcloud/quality gate” in addition to the build validation. I don’t think this part is obvious or well documented in what I have seen so far. I have seen plenty of documentation about adding the Build validation and how to do it but the status check i saw recently after specifically trying to research my particular issue. So I think this should be included in the labs and official documentation in a more obvious way.

But knowing this was not enough and here comes the second thing to consider.

  1. Now my issue is that i could not select SonarCloud/quality gate in the Status Checks because it simply was not available as a drop down option. It is supposed to be available after you trigger the build via a PR. I did this several times but i still could see it in the drop down. Then I came accross this which is the exact same issue I had and my problem was also solved by generating another PAT and replacing the one I had in SonarCloud → General Settings → Pull Requests. Now I could finally see it in the drop down

To the reader: Maybe make another PR if it still does not appear.

But this is what I mean by “bug” if that is the right word. There was nothing wrong with my previous PAT so why this needs to be replaced in order to get the SonarCloud/quality gate status check is cause for concern in my opinion.


I’m glad you worked through this. For the record, our official docs seem to cover the points you raised.


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