environment {
:
PROXY_HOST = "Nothing"
:
}
stage('deploy') {
steps {
script {
if (env.GIT_BRANCH == 'master') {
env.PROXY_HOST = env.PROXY_HOST_PRODUCTIVE
}
else if(env.GIT_BRANCH == 'develop')
{
env.PROXY_HOST = env.PROXY_HOST_ACCEPTANCE
}
else
{
env.PROXY_HOST = env.PROXY_HOST_DEV
}
}
echo env.PROXY_HOST // here it will still print Nothing
sh 'curl "$PROXY_HOST"' // here I need the variable again
I defined a variable in environment section of jenkinsfile (declarative) just to use it in an if...else construct. But it will never be reassigned . What can I do ?