Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

Jenkins Pipeline stage failure is carried over to other stages

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...