How do I get access to environment variables in my post block?

11 views
Skip to first unread message

red 888

unread,
Jan 23, 2018, 9:30:19 AM1/23/18
to Jenkins Users

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?


Reply all
Reply to author
Forward
0 new messages