I have a Jenkins Pipeline with three stages and want to make post action after each one. Problem occurs when the first or second stage fails, because stage failure is carried over to next stages, and failure post action is processed even the result is success.
pipeline {
stages {
stage('Hello') {
steps {
echo 'Hello World'
error('bad')
}
}
post {
failure {
echo 'first bad'
}
}
}
stage('Hello 2') {
steps {
echo 'Hello World 2'
}
post {
success {
echo 'second success'
}
failure {
echo 'second bad'
}
}
}
}
}
result:
Hello World
first bad
Hello World 2
second bad
expected result:
Hello World
first bad
Hello World 2
second success
Thank for any advice
question from:
https://stackoverflow.com/questions/65850345/jenkins-pipeline-stage-failure-is-carried-over-to-other-stages 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…