Dotnet sonarscanner PR analysis not updating from Harness

Template for a good new topic, formatted with Markdown:

  • ALM used

    • Azure DevOps
  • CI system used

    • Harness
  • Scanner command used when applicable (private details masked)

dotnet sonarscanner begin /o:org /k:foo / /d:sonar.token=... /d:sonar.pullrequest.key="1144" /d:sonar.pullrequest.branch="pr-trigger-fail" /d:sonar.pullrequest.base="main" /d:sonar.pullrequest.provider=vsts /d:sonar.pullrequest.vsts.instanceUrl= /d:sonar.pullrequest.vsts.project=foo /d:sonar.pullrequest.vsts.repository=Calculation

dotnet build .\api\Calculation.sln

dotnet sonarscanner end /d:sonar.token="..."
  • Languages of the repository

    • C#
  • 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

It’s a private project.

  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)

The PR analysis is not showing when executed from Harness, but works fine when executing the same command from local machine. The PR is shown in SonarCloud, but no code changes or issues reported when running from Harness.
Both environments generate identical .sonarqube\\out\\0\\Issues.json files (will send on request - 327 lines) with the same issues, but only reported correctly from local CLI.

See background task logs:

  • ID: AY0byse5LTqpqoTFXVhC (local)
  • ID: AY0bweaavPy3vj_zfsVC (Harness)
  • Steps to reproduce
  1. Run the CLI command in Harness
  2. Copy the command (printed out) to local, only updating the PR number (to show both side-by-side)
  3. Run the CLI command locally

After updating the PR number and running it locally, the PR analysis displays correctly in SonarCloud.

I’m running the commands in PowerShell scripts, so I doubt it’s specific to Harness, hoping I just missed something obvious where the background tasks might show you more.

Hey there.

Harness rings a bell in this exact same context. Can you take a look at this thread?

Thanks Colin - that thread was very useful!

I’ve updated my Pull Request Clone Strategy in Harness to ‘Source Branch’ (similar to the thread), but I also needed to run git fetch origin main for valid analysis.
I think it really just comes down to how the code is cloned and having the correct references on disk before running the scanner.

I’ve also updated this thread’s title to include Harness for reference…

1 Like

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