- 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.