Are there specific exit codes for the sonar-scanner? (Including the property sonar.qualitygate.wait)

Must-share information (formatted with Markdown):

  • sonar-scanner 5.0.1

What do I want to achieve:

I want to have different scenarios depending on the sonar-scanner execution, if I use the property sonar.qualitygate.wait. Which exit codes will be used when the scanner fails?

From the doc:

For other CIs, you can use the sonar.qualitygate.wait=true analysis parameter in your configuration file. Setting sonar.qualitygate.wait to true 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.

How can I detect if the sonar-scanner failed because of the quality gate or the execution? Is there a specific exit code to check? Something like quality gate failed is exit code 2?

Hi,

Quality Gate failure is not the same as scanner failure.

Unless your analysis errors-out (and sorry, I don’t know what the exit code would be) you’re going to get a 0 exit code whether the Quality Gate fails or succeeds. Instead, you need to retrieve and parse the QG status.

 
HTH,
Ann