简体   繁体   中英

Getting Method error : no such DSL method 'success' found among steps

I am trying to write a declarative Jenkins Pipeline which needs to echo that the job is successful if all previous stages are working as expected. If some stage fail post build must echo failed. But when I use the below pipeline its not working and it giving exception.

No such DSL method 'success' found among steps.Have I missed to install some plugin?

pipeline {
    agent {
        label 'Docker_sidharth_vijayakumar'
    }
    stages {
        stage('DEV') {
            steps {
                script {   
                    echo "Sidharth Vijayakumar"    
                }
            }
        }
        stage('UAT') {
            steps {
                script {
                    echo "Sidharth Vijayakumar"   
                }
            }
        }
        stage('PROD') {
            steps {
                script {
                    echo "Sidharth Vijayakumar"   
                }
            }
        }
    }
    post {
        always {
            success {
                echo ' Sucessful !"
            }

        }
    }
}

The success block should be outside of always block. It should be like this

post {
    success {
      script {
        echo ' Sucessful !"
      }
    }
}


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM