Hi
I have a pipeline which evaluates a variable to true or false, based on this I need to execute my next stage. I'm struggling to achieve this, please somebody help me as this is urgent I'm getting either pipeline failure or can't use when condition properly here is my snippet
stage ('test status'){
steps {
script {
env['status'] = sh(script: "docker inspect -f {{.State.Running}} testnode", returnStatus: true)
}
echo "${env.status}"
}
}
that stage gives me either 0 or 1 based on container is running or not, so if container not running I want execute a stage where I can start container else if already started, then kill previous container and start the new process how can I achieve this please
tried this but fails
stage('test true'){
when{
environment name:'status', value: '0'
}
steps {
echo ' ------ true ----- '
}
}
stage('test false'){
when{
environment name:'status', value: '1'
}
steps {
echo ' ------ false ----- '
}
}
if container status returned one in 'test status' stage , this failes as first stage is testing for 0 how can I run either o or 1 condition , please help me.