I'm a newbie to jenkins/groovy and I'm lost at string interpolation.
We're trying to read a list of steps from a configuration file (stored in json format) and execute some actions bases on it in jenkins pipeline script.
Configuration file:
{
"actions": [ {
"operation": "create",
"args": [
{ "path": "${env.SVNRoot}\\trunk\\ABC" },
{ "path": "${env.SVNRoot}\\trunk\\XYZ" }
]
}, {
"operation": "delete",
"args": [
{ "path": "${env.SVNRoot}\\trunk\\ABC" },
{ "path": "${env.SVNRoot}\\trunk\\XYZ" }
]
}
] }
Jenkins Pipeline code:
node('master') {
echo "${env.SVNRoot}" //String interpolation works here, giving the right value
stage('ReadConfig'){
cfg = readJSON file: 'Cfg.json'
}
stage('ExecuteConfigActions'){
cfg.fileActions.each() {
switch(it.operation) {
case 'create':
it.args.each() {
echo it.path //String interpolation doesnt work here
break;
default:
break;
}
}
}
}
}
How can I get string interpolation to work in such a scenario? Basically I want the environment variable value to be substituted in its placeholder and the path hence derived. I've tried single, double, escaped quotes to no avail.