in Jenkins declarative pipeline, is there a way to set a global environment var of a stage based on the output of the previous stage? I would like to be able to dynamically set an agent based on this. I have a code that does not work (below), but this illustrates what I am trying to do:
pipeline {
agent { node { label 'standard' } }
stages {
stage ('first') {
steps {
sh 'MYSTRING=`myapp.py getstring`'
}
}
stage ('second') {
agent { node { label "${MYSTRING}-agent" } }
...
}
}
}