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,380 points
1,708 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,280 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,880 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
980 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,240 points
50 views
0 votes
2 answers

What does the AWS CodeDeploy Jenkins Plugin do?

AWS CodeDeploy is AWS service that coordinates application ...READ MORE

answered Aug 8 in Jenkins by Sirajul
• 29,740 points
59 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
177 views
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,280 points
331 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,280 points
452 views