How to fail jenkins job if the sonar project does not pass Quality gate stage

Viewed 438

I am trying to run my sonar scanner from jenkins and I want my jenkins job to fail when the Quality gate at sonar is not met. I have configured sonar host and sonar scanner with jenkins at global tool level, my project analysis is uploaded in sonar, but the jenkins job is still passing. what am i doing wrong. so, basically I am trying to achieve this https://blog.sonarsource.com/breaking-the-sonarqube-analysis-with-jenkins-pipelines/ , I can do it via pipelines, but I want to achieve the same thing via a jenkins job. Here is my job just clone a project and run sonar scanner. this is the build step

git clone 'https://github.com/SonarSource/sonar-scanning-examples.git # clone
cd $WORKSPACE   # goto cloned workspace

Here are the properties passed to sonarscanner

Analysis properties:

    sonar.projectKey=org.sonarqube:sonarqube-scanner
    sonar.java.binaries=.
    sonar.qualitygate.wait=true

I believe sonar.qualitygate.wait=true this is the extra step that I need to do at sonar scanner step. I want my jenkins job to fail, as soon as Quality gate fails.

0 Answers
Related