Thank you for reaching out.
Have you tried to rerun the analysis on the pull request?
Do you still have this issue after the retry?
I cannot find a related error on our side for the given analysis. so I estimate that a network issue may be related.
The decoration happened for the pull request 1383 on the commit SHA d92e0755b7ca5e72bcb388973db11a5a43bb5514.
Do you confirm the pull request id with the same commit SHA value as the last commit on the related branch?
Yeah, it looks like the wrong SHA.
How can I see SHA that Sonar is using to decorate PR?
And it would be nice to get failure feedback somewhere in SonarCloud.
You can also find the commit SHA on the PR summary page.
Kindly note that the SonarCloud scanner gets the commit SHA from the git side when the analysis starts.
So if the commit SHA for the given branch is changed after the analysis started due to rebasing on the branch or any other reason, it will not be considered a failure from the SonarCloud side.
It checkout PR head and runs as expected, but when I execute the sonar scanner, sonarcloud.io provide a link to commit in the develop branch.
I tried to use different SonarQube lib GitHub - SonarSource/sonarqube-scan-action to execute the analysis, but the same result.
I thought I was working on the wrong branch, but I pushed the failing test to my PR branch, and the Github action failed on the test step. So I can conclude that GitHub Action checkout is the right commit.
I have added a git log message just before and after sonar scanning, and I see the expected commit sha.
I have outputted the github variable with
Kindly note that for the PR 1394, analyzed branch is “setup_github_actions_on_dev” and commit SHA is 4fd49393c944b609450a1421c8fb02f2097acbc6 and not e4f2ba913c28b64d8a103f2f49fd7482d0b4597b
The commit SHA e4f2ba913c28b64d8a103f2f49fd7482d0b4597b matches pull_request_key
1411on the branch setup_github_actions_on_dev on 2022-08-04T07:51:51.706Z.
ok, I think this is my problem.
Can I specify the scanner with my real commit SHA?
According to GH documentation REF:
Note that GITHUB_SHA for this event is the last merge commit of the pull request merge branch. If you want to get the commit ID for the last commit to the head branch of the pull request, use github.event.pull_request.head.sha instead.
I don’t think that you can specify the commit SHA for the scanner. because the scanner always takes into account the HEAD commit. Maybe the only way is to check out your PR with the specific commit and start analysis then.
Thanks for your reply.
I have just tried to run scanner with -Dsonar.scm.revision=${{github.event.pull_request.head.sha}} and it worked as expected.
Not sure if it is connected by we are building PRs from forks.