At the top of my pipeline (not inside a specific stage) I define an env:
environment {
MYVARRRR = 'sdkfjlsjflsjflsd'
}
Now I want to use it in a function call in my post block. I had to do this to get it to work:
post {
success {
script {
def MYVARRRR = MYVARRRR
myFunction {
someParam = "This is my var: ${MYVARRRR}
}
...
This works fine, but is there a more elegant shorthand for this? Maybe an annotation that will grab the var from the calling parent or something? Why do I have to redefine the variable?