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!
currentBuild.resultyou can set the status for the whole job. But if you only want to take decisions within your pipeline: how about using a normal groovy variable as a flag? If you set a variable within a global context you can use it across stages within the same build. Or maybe I'm not really getting the question right? - fishi0x01