GitHub vs SonarCloud Status Check Not Being Reported

Hi,

The organization I work for is experiencing a problem with our integration with GitHub. In some cases, the analysis status is not being sent back, and as we have a check against it, our Pull Requests are being blocked by that. It is an intermittent problem. I can see on SonarCloud that the analysis was successful; I can see a message sent to GitHub, as the PR has a comment from SonarCloud saying that the Quality Gate passed. Still, the “SonarCloud Code Analysis Expected — Waiting for status to be reported” is never cleared on checks.

This happens from time to time. Sometimes if you trigger the build again, it will be cleared, but this seems to become more common every day, and we need a solution for that. So how can we get support to have this analyzed and fixed?

Thank you.

Details:

  • ALM used: GitHub
  • CI system used: Jenkins
  • Scanner command:
${SONAR_SCANNER_HOME}/bin/sonar-scanner -X \
    -Dsonar.host.url=https://sonarcloud.io \
    -Dsonar.login=${env.SONAR_AUTH_TOKEN} \
    -Dsonar.pullrequest.provider=GitHub \
    -Dsonar.pullrequest.github.repository=${GITHUB_REPO} \
    -Dsonar.pullrequest.base=main \
    -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} \
    -Dsonar.pullrequest.key=${env.CHANGE_ID} \
    -Dsonar.projectVersion=${env.BUILD_NUMBER}
  1. Open a PR on GitHub
  2. Wait for Build to finish on Jenkins
  3. Check it was analysed on SonarCloud
  4. Check the SonarCloud message on GH PR informing it passed the Quality Gate
  5. Check the “SonarCloud Code Analysis” check is not cleared.
  • Potential workaround
    Sometimes triggering the CI pipeline to rebuild/re-run the analysis solves the problem.
1 Like

In my case, my organization is facing a similar issue and the workaround that we tried is merging the latest master again and again into the branch and build it again.

Any update on the fix?

Hello @marcusvnac.

For now it’s pretty hard to observe what’s the issue for lack of logs.

So when you have a recent PR that shows this issue, please, report to us so we can take a look to the logs and see if anything went wrong. Without these logs we are kinda blind.

Welcome to the community, @Navsheen! Do you have any recent PR where you observed this issue?

Best

Andrey.

Hey Andrey, I just got a new one with the problem.

Task ID: AYd7nx8cvVdzVM3q9jwH
April 13, 2023 - 11:17:18 AM
PR-3554

Hope that helps
Best,

Marcus.

Hey, one more for you:

ID: AYeRC9K6dx0IlEmL_bZs

April 17, 2023 - 3:08:04 PM

Hi @marcusvnac.

I hope everything goes alright with you.

I’ve been investigating the issue with the help of my colleagues, specially about the PR-3554. We could pin point this PR in our logs and investigate a bit the possible causes of the problem.

So, in short, the job that gives the status check to commits failed with a status 422. After further investigation from my colleagues, we found out that this error happens when our back-end fails to find the commit related to that check. And this might happen for many reasons, for example, when the history changes, or when the check is ran on a merge commit (where commits are squashed), or things like that.

That said, I would like to know from you if you find a specific commit on your code base: 51ffde2ee3a8c8e3bb1a7af91b0d5bbd9db31d51. This is the commit that was expected to be given the status check, but was not found.

Another question for you, do you have on your CI any Git manipulation mechanism that could lead to lost commits, somehow? I don’t mean that the problem is on your workflow, but I just want to understand what could lead to a missing commit error.

Looking forward for your answer.

Cheers.

Hey Andrey,

I couldn’t find this commit in my main branch, as it was a commit in the branch that originated the PR. Below you can see the build from Jenkins, with that same SHA that you shared. When the PR is merged, our policy is to use squash merge and delete the branch.

I don’t know how/why it didn’t find this specific commit to report the status back, as this branch/PR stayed open for a while after that, and at least three more builds happen to it after that.

To your question, no, our CI doesn’t manipulate the changes.

image.png

Best,

Marcus

Hello Marcus.

I’ve been investigating your issue a lot in the past few days.

And with your last message we were able to build some possible scenarios where this could happen. I’m not sure if this is the case of these PRs you sent me, though.

One scenario that could trigger that is a PR with 2 commits. During the Analysis of the last commit, you squash locally and force push the branch. In theory, the analysis of the last commit (which doesn’t exist anymore) should be stopped. If this doesn’t happen, this issue might happen. Do you know if this might happen in the lifecycle of your branches?

We also found a thread where a user experiences the same issue: SonarCloud+GitHub=No PR check - #22 by PavelA85

Check the solution for the thread. Is your pipeline using the same technique to get the revision to be analysed?

I think we are very close to find out what’s going on. For now I will unassign this thread, and if you still have issues after applying the recommendation, feel free to ping here again.

Cheers.

Hey Andrey,

I don’t believe the scenario you described is what we have here, but I’ll add the Dsonar.scm.revision= in our script to see if it solves the problem.

Thanks.

1 Like