In my pipeline, I have a stage that checks to see if a specific computer (node) is offline. If it is, I want to skip the next stage. However, the next stage is set to use the offline agent, so it doesn't seem to be able to check the When clause.
Here's a simplified version of my pipeline:
pipeline {
agent none
environment {
CONTINUERUN = true
}
stages {
stage('Check Should Run') {
agent any
steps {
script {
CONTINUERUN = false
}
}
}
stage('Skip this stage') {
agent {
label 'offlineAgent'
}
when {
expression {
CONTINUERUN
}
}
steps {
//Do stuff here
}
}
}
}
When I run this, the build just hangs at the 'Skip this stage' stage. I'm assuming, because the agent is offline. How can I skip this stage, when the agent is known to be offline?