Hi, I have issue porting scripted to declarative pipeline. I used to have in scripted: //Scripted def myEnv = [:]
stage ('Prepare my env') { [...] myEnv = ... } stage ('Fancy stuff') { node() { withEnv(myEnv} { // here use what is defined in myEnv } } stage ('Fancy stuff2') { node() { withEnv(myEnv} { // here use what is defined in myEnv } } } and now in declarative I would like to have //Declarative def myEnv = [:] pipeline { agent none stage('Prepare my env') { steps { script { [...] myEnv = ... } } } stages { environment { myEnv } stage('Fancy stuff') { [...] } stage('Fancy stuff2') { [...] } } } when I try to run this, it fails withEnv "org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: xx: "myEnv" is not a valid environment expression. Use "key = value" pairs with valid Java/shell keys. " Fair enough. What should I do to be able to use declarative environment { } to avoid using the declarative one in every further steps? Thank you, Bob. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1aaa1380-0386-4fe4-8652-a96b06468279%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.