How do we get the status of the preceding stage(s) in a Jenkins pipeline. For example: My example pipeline is as under:
pipeline {
agent
{
node {
label 'master'
customWorkspace "${env.JobPath}"
}
}
stages
{
stage('Start') {
steps {
sh 'ls'
}
}
stage ('set_env') {
steps {
// script to set environment.
}
}
stage ('Build') {
steps {
// script to build.
}
}
stage ('Send_mail') {
steps {
// script to send mail.
}
}
stage('End') {
steps {
sh 'ls'
}
}
}
}
How can i get the status of a particular stage in a pipeline. for ex: i want to take certain decisions based on whether the "Build" stage was a success or a failure.
Is there any environment variable which tracks the status of every stage, or there's a Jenkins REST API which can help me achieve this.
Thanks!