Hi Ann,
Thank you so much for your kind reply. I already referred the sonar document you shared and …I tried with both scripted and declarative pipeline script even by separating the stages but getting errors below. Please correct me if im doing wrong. Thank you.
Scripted pipeline
WorkflowScript: 59: Unknown stage section “sleep”. Starting with version 0.5, steps in a stage must be in a ‘steps’ block. @ line 59, column 8.
stage(‘Quality Gate’) {
^
WorkflowScript: 59: Unknown stage section “timeout”. Starting with version 0.5, steps in a stage must be in a ‘steps’ block. @ line 59, column 8.
stage(‘Quality Gate’) {
^
WorkflowScript: 59: Expected one of “steps”, “stages”, or “parallel” for stage “Quality Gate” @ line 59, column 8.
stage(‘Quality Gate’) {
^
code snippet :
stage(‘Sonarqube Analysis’) {
environment {
scannerHome = tool ‘ALM Sonar’
}
steps {
withSonarQubeEnv(‘ALM Prod Sonar’) {
sh “{scannerHome}/bin/sonar-scanner"
}
}
}
stage('Quality Gate') {
sleep time: 3000, unit: 'MILLISECONDS'
timeout(time: 1, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: {qg.status}”
}
}
}
Declarative pipeline -
For declarative pipeline getting below error - Invalid parameter “abortPipeline”, did you mean “null”?
ERROR :
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 64: Invalid parameter “abortPipeline”, did you mean “null”? @ line 64, column 40.
waitForQualityGate abortPipeline: true
Code -
stage(‘Sonarqube Analysis’) {
environment {
scannerHome = tool ‘ALM Sonar’
}
steps {
withSonarQubeEnv(‘ALM Prod Sonar’) {
sh “${scannerHome}/bin/sonar-scanner”
}
}
}
stage(“Quality Gate”) {
steps {
timeout(time: 1, unit: ‘HOURS’) {
// Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
// true = set pipeline to UNSTABLE, false = don’t
waitForQualityGate abortPipeline: true
}
}
}