Checks not showing in GitHub

  • ALM used: GitHub

  • CI system used: TeamCity

  • Scanner command used when applicable (private details masked)
    dotnet %teamcity.tool.sonar-scanner-msbuild-5.5.3.43281-net5.0%\SonarScanner.MSBuild.dll
    /d:sonar.pullrequest.key=%teamcity.pullRequest.number%
    /d:sonar.pullrequest.branch=“%teamcity.pullRequest.source.branch%”
    /d:sonar.pullrequest.base=“%teamcity.pullRequest.target.branch%”

  • Languages of the repository
    c#, TypeScript some SQL

  • 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
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
    I’m trying to use Sonar as a Quality gate. It’s responding to requests to scan & I can see the PR scan in SonarCloud. It even adds a comment to the PR. What it doesn’t do is appear as a check, so when the quality gate fails, it just adds a comment, which is useless.

How do I make Sonar scans appear as a check in GitHub?
image

  • Steps to reproduce
  • Potential workaround

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hey there.

This sounds like an issue where SonarCloud tries to decorate a virtual “merge” commit that doesn’t exist on the GitHub side, which is required when posting a GitHub Check.

However, there’s no such limitation on adding a comment to a PR (it’s not tied to a commit) which is why you end up with functionality that “kind of” works.

To confirm – I would suggest increasing your analysis log level to DEBUG /d:sonar.verbose=true and looking for a line like the following in your scanner logs.

11:22:03.341 DEBUG: SCM revision ID ‘217629197df33b1d8839a8ce90dc19b5c53d485d’

For a given pull request (that you don’t receive a check for), does the SCM revision reported in the logs match one that actually exists in your pull request?

I solved this by adding the sonar.scm.revision property to the scanner.

Thanks for your help