-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
Jenkins 2.48
Linux (CentOS)
SonarQube 6.2
It appears that stage like these are not possible?
stage ("SonarQube analysis") { steps { script { STAGE_NAME = "SonarQube analysis" if (BRANCH_NAME == "develop") { echo "In 'develop' branch, don't analyze." } else { // this is a PR build, run sonar analysis withSonarQubeEnv("SonarGate") { sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner" } } } } } stage ("SonarQube Gatekeeper") { steps { script { STAGE_NAME = "SonarQube Gatekeeper" if (BRANCH_NAME == "develop") { echo "In 'develop' branch, skip." } else { // this is a PR build, fail on threshold spill def qualitygate = waitForQualityGate() if (qualitygate.status != "OK") { error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}" } } } } }
It fails with: "Please use the 'withSonarQubeEnv' wrapper to run your analysis.", but I am using it... Jenkins does not recognize it? full logs in the question link above.
[JENKINS-42954] Jenkins unable to operate SonarQube block
Assignee | Original: Sonar Team [ sonarteam ] | New: Idan Adar [ idanadar ] |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Open [ 1 ] | New: Resolved [ 5 ] |
Status | Original: Resolved [ 5 ] | New: Closed [ 6 ] |
Description |
Original:
(Based on: [https://stackoverflow.com/questions/42909439/using-waitforqualitygate-in-a-jenkins-declarative-pipeline)] It appears that stage like these are not possible? stage ("SonarQube analysis") { steps { script { STAGE_NAME = "SonarQube analysis" if (BRANCH_NAME == "develop") { echo "In 'develop' branch, don't analyze." } else { // this is a PR build, run sonar analysis withSonarQubeEnv("SonarGate") { sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner" } } } } } stage ("SonarQube Gatekeeper") { steps { script { STAGE_NAME = "SonarQube Gatekeeper" if (BRANCH_NAME == "develop") { echo "In 'develop' branch, skip." } else { // this is a PR build, fail on threshold spill def qualitygate = waitForQualityGate() if (qualitygate.status != "OK") { error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}" } } } } } It fails with: "Please use the 'withSonarQubeEnv' wrapper to run your analysis.", but I am using it... Jenkins does not recognize it? full logs in the question link above. |
New:
(Based on: [https://stackoverflow.com/questions/42909439/using-waitforqualitygate-in-a-jenkins-declarative-pipeline)] It appears that stage like these are not possible? {code:java} stage ("SonarQube analysis") { steps { script { STAGE_NAME = "SonarQube analysis" if (BRANCH_NAME == "develop") { echo "In 'develop' branch, don't analyze." } else { // this is a PR build, run sonar analysis withSonarQubeEnv("SonarGate") { sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner" } } } } } stage ("SonarQube Gatekeeper") { steps { script { STAGE_NAME = "SonarQube Gatekeeper" if (BRANCH_NAME == "develop") { echo "In 'develop' branch, skip." } else { // this is a PR build, fail on threshold spill def qualitygate = waitForQualityGate() if (qualitygate.status != "OK") { error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}" } } } } } {code} It fails with: "Please use the 'withSonarQubeEnv' wrapper to run your analysis.", but I am using it... Jenkins does not recognize it? full logs in the question link above. |