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,360 points
1,194 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,080 points
0 votes

Use Webhooks in SonarQube Administration setup to configureit: https://docs.sonarqube.org/display/SONAR/Webhooks

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

Result might be either "OK" or "failure"

answered Aug 3, 2018 by Nilesh
• 6,900 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
365 views
0 votes
1 answer

sonar XML plugin installation failure in jenkins

You can try this link which SonarQube XML ...READ MORE

answered Jun 20, 2018 in Jenkins by Atul
• 10,220 points
30 views
0 votes
1 answer

What does the AWS CodeDeploy Jenkins Plugin do?

The AWS CodeDeploy Jenkins Plugin provides a ...READ MORE

answered Apr 15 in Jenkins by Uzaa
38 views
+13 votes
2 answers
0 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,080 points
213 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,080 points
213 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.