1

I have created a parameterized pipeline project in jenkins but i am not able to access those parameters in shell script

Below is the script i am using in pipeline

node {
echo "Download files from FTP"
sh '''
# read servers details for the instance selected
keyName=`$(cat ServerDetails.json | jq .rdpEnv.${params.Instance}.keyName)`

}

It is failing with below error

cat ServerDetails.json
/var/lib/jenkins/workspace/CPS Instance Update - AWS@tmp/durable- 
bd57b5d5/script.sh: line 4: .rdpEnv.${params.Instance}.keyName: bad 
substitution
cat: write error: Broken pipe
keyName=
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
vinay
  • 1,004
  • 1
  • 11
  • 27
  • this might be additional question, but is it possible to pass variable in single quotes statement in groovy – vinay May 30 '18 at 06:04
  • it isn't clear what you mean. Single versus double quotes controls how string interpolation works. In your original you use a triple-single quoted string, so `${params.Instance}` will be the literal string `${params.Instance}` instead of the interpolated value from the pipeline context. – mkobit May 30 '18 at 13:51

0 Answers0