Home > Software design >  Getting Method error : no such DSL method 'success' found among steps
Getting Method error : no such DSL method 'success' found among steps

Time:05-12

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 !"
            }

        }
    }
}

CodePudding user response:

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

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


  • Related