Setting Sonar Scanner as part of pipeline

I am trying to setting up SonarQube analysis as part of the pipeline job

And I am using the sonar scanner as told. It is working fine but is that possible to fail the Jenkins job if the Quality Gate checking is failed.

It detected the Quality Gate as intended and failed as intended. I need a way to force abort this job if the quality gate failed (without using the withSonarQubeEnv and waitForQualityGate).

Hey there.

The scanner is issuing a non-zero exit code when the Quality Gate is failed, which should fail the pipeline. Is that not happening in your case?

That is not happening. :smiling_face_with_tear: I have tried everything I could (literally everything). The job just continues as normal even the quality gate failed.

Issue resolved. Apparently, Jenkins shell command always retrieve the last command as the exit code. In my case, after running the Sonar Scanner, I tried to echo something. The echo command is being took in as the success exit code instead of the Sonar Scanner failure exit code. Hope this helps people who face the similar situation in future.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.