Is there a way for Travis to determine that a code analyse has completed

  • Using SonarQube v3.3
  • What we are trying to achieve?
    We are using Travis to run multiple checks and scans including SonarQube. After starting the scan we immediately make a curl call to retrieve the quality gate (see below).
- stage: scan
  name: "gradle sonarscan (jdk11)"
  jdk: openjdk11
  script:
    - ./gradlew buildDists sonarqube -Dsonar.login=$SONAR_LOGIN
    - curl -s https://sonarcloud.io/api/project_badges/quality_gate?project=opendap-olfs | grep "QUALITY GATE PASS"

When we run the sonar scan we have noticed on SonarCloud.io the analysis will continue running after Travis has completed the command and made the curl call.
This means Travis is retrieving the previous analysis result instead of the current analysis result.
So what we are asking: Is there a way to check if an analysis is done and/or running using a curl call?

  • What have we done to achieve this?
    We have looked for documentation on this matter and found none. We have also tried to use a curl call to search for the “Analysis in progress. This could take up to 30 minutes” banner that sometimes shows up but had no success on this.
    Any and all help on this matter will be appreciated.

Hi,

Welcome to the community!

I guess you’re using a 3.3 version of a SonarScanner…?

Also, it’s not clear to me whether your question is about SonarQube or SonarCloud.

Either way, you can configure the server to send a webhook call once server-side processing of the analysis report is complete. Assuming Travis can ‘catch’ the webhook, you’ll find Quality Gate status and relevant metrics in the payload.

That’s really the cleanest solution.

 
HTH,
Ann

Hi again,

It has been pointed out to me that I keep forgetting about sonar.qualitygate.wait, which according to the docs :

forces the analysis step to poll your SonarQube instance until the Quality Gate status is available. This increases the pipeline duration and causes the analysis step to fail any time the Quality Gate fails, even if the actual analysis is successful. You should only use this parameter if it’s necessary.

 
HTH,
Ann