When I specify an agent inside a stage, it then also applies to everything in the 'post' section.
I'm not sure that is alway the behavior I want.
Is there a way around this?
Specifically, we have the ability to take a checkpoint (similar to the enterprise edition checkpoint feature) but that should run outside the node.
Currently we can do this in script world:
node('java-1.8.0_45') {
stage ('Master Build') {
checkout scm
sh 'do some building'
}
}
captureSnapshot('BuildComplete')
node('java-1.8.0_45') {
stage ('Dev Deploy') {
sh 'do some deploying'
}
}
captureSnapshot('DeployComplete')
In declarative syntax land, the post actions
pipeline {
agent none
stages {
stage ('Build') {
agent { label "java-1.8.0_45" }
steps {
checkout scm
sh 'do some building'
}
post {
success {
captureSnapshot('BuildComplete') // this is still inside the node
}
}
}
stage ('Dev Deploy') {
agent { label "java-1.8.0_45" }
steps {
checkout scm
sh 'do some deploying'
}
post {
success {
captureSnapshot('DeployComplete') // this is still inside the node
}
}
}
}
}
Do I have to setup another stage specifically for the captureSnapshot? I really don't want to see that stage visually show up on my pipeline all over the place.