PR analysis failing. How to trigger PR analysis directly from SonarCloud?

Sonarcloud PR analysis action fails intermittently.

Impact: this check is mandatory for PR to be merged to main trunk. If this check fails, PR get can not be merged and hence dev flow is blocked.

In the failed github check, we see messages as (screeshot attached):


SonarCloud / SonarCloud Code Analysis
cancelled 7 days ago in 3m 43s
SonarCloud analysis failed
Please retry analysis of this Pull-Request directly on SonarCloud

at the same time:

  • PR decoration is available on PR
  • PR analysis on SonarCloud shows passed

Two questions:

  1. why is it failing? background task logs are showing:
Error Message
Validation of project failed:
  o Date of analysis cannot be older than the date of the last known analysis on this project. Value: "2021-09-27T16:40:22+0000". Latest analysis: "2021-09-27T16:41:00+0000". It's only possible to rebuild the past in a chronological order.
  1. How to trigger analysis from sonarcloud as suggested in the github check?
  • ALM used GitHub
  • CI system used Github actions
  • Languages of the repository java/python
  • Problem with PR github action:
  • Error observed screenshot attached
  • Steps to reproduce None:Intermittent issue

  • workaround:
    manually trigger github action job that re-analyses the project and then sonarcloud analysis gets successfull.

Hi @dhavaltdesai,

Seeing the logs and the error message you get, is it sometimes happening that 2 builds / analysis gets triggered for the same commit ? If yes, you might want to have one SC analysis being finished before proceeding to another build, otherwise you don’t know when which analysis comes first, and that lead to those kind of messages.

HTH
Mickaël

Thanks for your quick response @mickaelcaro :slight_smile:

I’ll have to find out what is causing back to back analysis requests. As of now, two events can trigger this build in github actions: ON PUSH and ON PULL_REQUEST.

Any pointers for second question?
How to trigger analysis from sonarcloud as suggested in the github check?

I think this one is misleading, i’m gonna check with my colleagues whether this is still making sense. For now, i would suggest to trigger the build from GH actions instead.

1 Like

Hey, @mickaelcaro, I’d like to share my experience with this problem. I was having the exact same error, and it seems that the LOC limit was reached, but the message on github says nothing about it. And in multiple scans, nothings clear was said on SonarCloud too. The misleading message lead us to keep trying, thinking that some config was wrong. Fixing that to provide a clear message would be very appreciated! Thank you