SQ REST API doesn't return analysis ID

  • SQ version Community Build v25.5.0.107428
  • SonarQube is deployed via Docker
  • I want to get analysis ID via SonarQube REST API
  • After successful analysis using mvn verify sonar:sonar I used command

ANALYSIS_ID=$(curl -s -u "$SONAR_PROJECT_TOKEN: $SONAR_HOST_URL/api/project_analyses/search?project=$PROJECT_KEY | jq -r ‘.analyses[0].key’)

but ANALYSIS_ID is empty

Hi,

Can you explain what you want to do with the analysis ID? Also, can you explain your timing?

Because the “analysis” as such doesn’t exist in the DB to be queried until after background task processing is complete. And, as you’ve observed, it’s not a particularly rich data set that comes back from that endpoint.

 
Ann