So I have an environment in a Jenkins declarative pipeline script that looks something like this:
pipeline {
environment {
PATH1 = 'C:\\Users\\Administrator\\Documents'
PATH2 = '${env.PATH1}\\more_stuff'
}
// etc...
But when I try to access PATH2 in anything, it transcribes the literal "${env.PATH1}" into it rather that the environment variable PATH1.
I have tried ${env.PATH1}
, ${PATH1}
, %PATH1%
, but none of them work. How do I access environment variables while declaring other environment variables?
I will assume you are trying to use Groovy string interpolation.
Groovy string interpolation is only performed on double quoted strings, not single quoted strings.
I believe what you want is
PATH2 = "${env.PATH1}\\more_stuff"