S
S
Syrex2018-03-20 17:21:51
Jenkins
Syrex, 2018-03-20 17:21:51

Jenkins. How to get value from ERROR?

Installed Jenkins 2.89.4 + Pipeline plugins Pipeline
code:

pipeline{
    agent any
    stages{
        stage('INIT'){
            steps{
                script{
                    error 'My Error in Stage'
                }
            }
        }
    }
    post{
        success {
            echo "post success"
        }
        failure{
            echo "post failure"
        }
    }
}

In the Jenkins log, we see the following lines:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in d:\tmp\JenkinsWS\TEST
[Pipeline] {
[Pipeline] stage
[Pipeline] { (INIT)
[Pipeline] script
[Pipeline] {
[Pipeline] error
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
post failure
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: My Error in Stage
Finished: FAILURE

Question: how to get the value My Error in Stage in the post.failure block

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question