According to the Jenkins docs, this is how one sets a Global Environment Variable for a Declarative Pipeline:
pipeline { agent { label 'my-label' } environment { value = 'World' } stages { stage("Test") { steps { sh 'echo Hello, ${value}' } } } } The output is "Hello, World" as expected.
What is the correct way to do this in a Scripted Pipeline? The following does not error, but it does not work:
node('my-label') { environment { value = 'World' } stage("Test") { sh 'echo Hello, ${value}' } } The output is "Hello, ". That is not as expected.