What possible return values are there in Jenkins plugin Sonarqube scanner

+1 vote

I build my application through a Jenkins pipeline job, made a sonar analysis and then passed the quality gate, i deploy it in nexus with mvn deploy.

Initially I only wanted to publish in case of success

stage("Quality Gate"){
      timeout(time: 1, unit: 'HOURS') {
          def qg = waitForQualityGate()
          if (qg.status != 'OK') {
              error "Pipeline aborted due to quality gate failure: ${qg.status}"
          }
      }
    }

But now I want to the logic gate a bit in jenkins so that I can publish even if there's no error.(warning may come)

So I changed the jenkins stage to:

stage("Quality Gate"){
  timeout(time: 1, unit: 'HOURS') {
      def qg = waitForQualityGate()
      if (qg.status == 'Error') {
          error "Pipeline aborted due to quality gate failure: ${qg.status}"
      }
  }
}

stage('Deploy to Nexus') {
    sh "mvn deploy -DskipTests"
}

But this doesn't seem to work. the project is always pushed to nexus even if the quality gate gives error in sonarqube.

a possible workaround could be by changing the condition:

qg.status != 'OK' || qg.status != 'Warning' 

Can anyone tell me the possible values for the error status.

Mar 28, 2018 in Jenkins by DragonLord999
• 8,450 points
4,734 views

2 answers to this question.

0 votes

I don't think there's another way other than guessing the correct value.

to prevent such issues, I suggest to test without exact case like this:

if ('error'.equalsIgnoreCase(qg.status) ) {
    error "Pipeline aborted due to quality gate failure: ${qg.status}"
} 

With this condition my script works fine.

the calue returned is 'ERROR'

answered Mar 28, 2018 by ajs3033
• 7,300 points
0 votes
Use Webhooks in SonarQube Administration setup to configure it.

This method returns whatever you have configured for all Gateway Rules.

Result might be either "OK" or "failure"
answered Aug 3, 2018 by Nilesh
• 7,060 points

Related Questions In Jenkins

0 votes
1 answer

What are parameterized jobs in jenkins and how to configure it?

Hey @Hannah, Parameterized jobs/builds are the ones ...READ MORE

answered Dec 16, 2018 in Jenkins by Kiyara
5,087 views
0 votes
2 answers
0 votes
1 answer

What is the difference between the Jenkins jobs which are in workspace directory and jobs directory

Hi@Shashi, These folders have different meanings in Jenkins. If ...READ MORE

answered Oct 21, 2020 in Jenkins by MD
• 95,460 points
3,978 views
0 votes
1 answer

What is the use of audit trail plugin in Jenkins?

Hi@akhtar, Audit Trail Plugin keeps a log of ...READ MORE

answered Dec 7, 2020 in Jenkins by MD
• 95,460 points
1,318 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,024 views
+2 votes
1 answer
0 votes
1 answer

How can I create global macros and templates in jenkins job builder?

you can append the path to the ...READ MORE

answered Apr 2, 2018 in Jenkins by ajs3033
• 7,300 points
1,853 views
0 votes
1 answer

Which is better jenkins of TFS 2015 for CI/CD?

Visual Studio and TFS have been using ...READ MORE

answered Aug 21, 2018 in Jenkins by ajs3033
• 7,300 points
2,219 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP