I have problem with method waitForQualityGate(). I got an error "No such 
DSL method 'waitForQualityGate' found among steps". Another strange thing 
is that I must use parameter -DXfor sonarscanner. I don't know what is 
wrong. Thanks for help.

pipeline {
agent { label 'builders' }

tools {
    maven 'maven 3.3.9'
}

stages {
    stage ('Checkout'){
        steps {
            git branch: 'develop', credentialsId: 'credential', url: 
'ssh://repository'
        }
    }
    stage ('Build'){
        steps {
            withMaven (
                maven: 'maven 3.3.9',
                mavenSettingsConfig: 'cc86690e-095d-4714-92b2-b61861241c7a'){
                sh 'mvn -U clean package -DskipTests'
            }
        }
    }
    stage ('SonarQube Scan'){
        steps {
            withSonarQubeEnv('SonarQube') {
                withMaven (
                    maven: 'maven 3.3.9',
                    mavenSettingsConfig: 
'cc86690e-095d-4714-92b2-b61861241c7a'){
                    sh 'mvn 
org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar ' +
                    '-Dsonar.issuesReport.json.enable=true' +
                    '-Dsonar.report.export.path=sonar-report.json'
                }

            } // SonarQube taskId is automatically attached to the pipeline 
context
        }
    }
    stage ('Quality Gate') {
        steps {
                timeout(time: 1, unit: 'HOURS') { // Just in case something 
goes wrong, pipeline will be killed after a timeout
                script {
                    def qg = waitForQualityGate() // Reuse taskId previously 
collected by withSonarQubeEnv
                    if (qg.status != 'OK') {
                        error "Pipeline aborted due to quality gate failure: 
${qg.status}"
                    }
                }
            }
        }   
    }
}


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5f624574-d52b-4cfa-ab42-88bb42df9e37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to