ADO PR Decoration from non-ADO pipeline (cli)

  • ALM used - Azure DevOps
  • CI system used - Harness (dotnet sonarscanner cli)
  • C# Repositories

Hi, We are trying to integrate SonarCloud into our CI pipeline within Harness using dotnet-sonarscanner cli. We are able to see the PR’s within SonarCloud under the project, along with the full report as expected, but we are unable to get the PR Decoration working within ADO. I am unable to provide links as these are private repositories.

dotnet tool install --global dotnet-sonarscanner

dotnet sonarscanner begin /o:"xxxx" /k:"<+pipeline.repo>" /d:sonar.host.url="https://sonarcloud.io." /d:sonar.token="xxxx" /d:sonar.pullrequest.key=<+codebase.prNumber> /d:sonar.pullrequest.branch=<+codebase.sourceBranch> /d:sonar.pullrequest.base=<+codebase.targetBranch> /d:sonar.pullrequest.provider='Azure DevOps Services' /d:sonar.cs.opencover.reportsPaths=/harness/coverage/*/coverage.opencover.xml

dotnet build --no-incremental

dotnet test --no-build --verbosity normal --logger "junit" --results-directory "/harness/coverage" --collect:"XPlat Code Coverage;Format=cobetura,opencover" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura,opencover

dotnet sonarscanner end /d:sonar.token="xxxx"

The differences in this configuration that i can see (vs ADO Pipeline) is that the harness build is triggered as “Status Check” rather than a “Build Validation”. We are not seeing the Status Check (SonarCloud/quality gate) being created within ADO by SonarCloud when the pipeline is ran.

Our PAT token is set at organization level but have also played around with setting the pr provider and token via the begin command, and also at project level in SonarCloud UI.

Hey there.

Due to a bug (in our backlog), you have to make sure that a couple internal analysis parameters are completed if you’re operating outside of Azure Pipelines and the Azure DevOps Extension. This shouldn’t be neccssary as SonarCloud should use the binding data.

You can find more details here:

I guess those build variables won’t be available to you in Harness, but if you can populate that same data you should be able to get PR decoration working.

Hi Colin, Thank you for your quick response. PR decoration is now working by adding the missing parameters as suggested. Thanks!

1 Like

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