How can I set a new environment variable from within a Jenkinsfile
using declarative pipeline?
I know that I can read environment variables using env
like this one for example ${env.JOB_NAME}
.
But how can I set a new environment variable which can be be used by my build script for example. I want to do something like below. Is this the correct way?
stage("build_my_code") {
steps {
sh 'MY_ENV_VAR="some_value"'
sh './my_script.sh $MY_ENV_VAR'
}
}