Jenkins Pipeline - Set process.env variable from build parameter

Viewed 4012

In my Jenkins feature file I have set a build parameter using:

  parameters {
        string(defaultValue: "http://xxx.xxx.xxx.xxx:1xxx/",
              description: 'Which environment to run on',
              name: 'Environment')
    }

Initially, I attempted to use the environment block to set this as a process.env variable however realised that I can't access it using the standard ${params.Environment}.

So i found it can be accessed in the steps/script block however how do I set it a process.env variable so that my code can see it:

steps {
        script {
          //def process.env.MYENVTEST = "${params.Environment}"
          ...
        }
      }
1 Answers
Related