SonarCloud in Jenkins Pipeline does not update GitHub PR and Check

Hello, I am experiencing similar issue to SonarCloud now not updating GitHub PR and Checks

albeit with the different project setup.
SonarQube Scanner for Jenkins 3.3.0.1492
Jenkins: 2.171

sonar-scanner
-Dsonar.projectKey=crossplaneio_crossplane
-Dsonar.projectName=crossplane
-Dsonar.organization=crossplane
-Dsonar.sources=.
-Dsonar.pullrequest.base=master
-Dsonar.pullrequest.branch=PR-374
-Dsonar.pullrequest.key=374
-Dsonar.pullrequest.provider=github
-Dsonar.pullrequest.github.repository=crossplaneio/crossplane

The Analysis runs successfully and results in successfully uploaded report:

23:15:38 INFO: ANALYSIS SUCCESSFUL, you can browse SonarCloud
23:15:38 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
23:15:38 INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AWoAvNvJ8FPh9JKrfqhN
23:15:38 INFO: Analysis total time: 13.791 s
23:15:38 INFO: ------------------------------------------------------------------------
23:15:38 INFO: EXECUTION SUCCESS
23:15:38 INFO: ------------------------------------------------------------------------
23:15:38 INFO: Total time: 16.883s
23:15:38 INFO: Final Memory: 42M/955M
23:15:38 INFO: --------------------------

However, the PR Check is not created.
I am new to SonarCloud and I suspect I have provided incorrect/incomplete configuration for the Analysis job.
Could someone please take a look to help me out with this?

Hi,

Please check if the sha1 of the analysis matches the HEAD of the PR. This will not be the case for example if your build pipeline does a merge commit first before running SonarCloud analysis. In that case the sha1 will be different from the HEAD of the PR. And in that case decoration is skipped, because it wouldn’t be visible anyway, being a temporary local commit.

Also, when you open your PR on SonarCloud, do you see a warning in the top-right part of the UI? (a box with yellow background)

Hello Janos, thank you for prompt reply.
My pipeline does not make any commits on the projects. Just in case, where do I find the sha1 of the analysis?

Thank you for looking into this.

Hi Janos,

It was indeed HEAD of the PR mismatch. While the pipeline itself does not do anything special with git checkout, the Jenkins job configuration did, by applying strategy: Both the current pull request revision and the pull request merged with the current target branch revision which resulted in new sha1 which did not exist on the remote side.

Switching to The current pull request revision strategy fixed the issue and SonarCloud Analysis PR check is set as expected.

Thank you

1 Like

We have plans to improve this behavior. You can track progress (and vote on) this ticket.