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

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

我正在尝试编写一个声明性的 Jenkins 管道,如果前面的所有阶段都按预期工作,它需要回应作业成功。如果某个阶段失败 post build must echo failed。但是当我使用下面的管道时它不工作并且它给出异常。

在 steps.Have 中找不到这样的 DSL 方法 'success' 我错过了安装一些插件?

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

        }
    }
}

success 块应该在 always 块之外。应该是这样

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