'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 !"
}
}
}
}
Solution 1:[1]
The success block should be outside of always block. It should be like this
post {
success {
script {
echo ' Sucessful !"
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dashrath Mundkar |
