I have written a shell script which is using curl command to build a Jenkins job with parameters. Following is the code.
#!/bin/bash
val3=( $(cut -d ',' -f3 csvfile.csv) )
printf "%s\n" "${val3[0]}"
echo $val3
curl -X POST https://my-jenkins.abc.com/inst/job/Aut/job/pipe-workflow/job/Job3/build \
--user user:token \
--data-urlencode json='{"parameter": [{"name":"valA", "value":"${val3}"}]}'
I am reading a file called as 'csvfile.csv' and passing the value of $val3 in the curl command. The output of $val3 is 'John'. I am not able to substitute the value of $val3 in the curl. It is taking it literary. I also tried following but none of them helped.
--data-urlencode json='{"parameter": [{"name":"valA", "value":"$val3"}]}'
--data-urlencode json='{"parameter": [{"name":"valA", "value":"${val3[0]}"}]}'
--data-urlencode json='{"parameter": [{"name":"valA", "value":"val3"}]}'
--data-urlencode json='{"parameter": [{"name":"valA", "value":"${val3}"}]}'
--data-urlencode json="{"parameter": [{"name":"valA", "value":"${val3}"}]}"
None of the above is working. The last one is throwing error. When I see in Jenkins job, the value of parameter is as following:
$val3, val3, ${val3}
It is taking it as it is than substituting the value.
printf "%s\n" "${val3[0]}"
echo $val3
The above two lines are giving me output as John but while putting it in curl, its not working. What is causing this and how do I fix it?
Thank you in advance
An error occurred processing your request. Ask your Jenkins administrator to look up details. ErrorID=864a6488-2aef-4804-b001-55aefd4910b0
Stack trace suppressed by the suppress stack trace plugin It works fine with singlr quote outside, I think. I referred the post for Jenkins from here https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API – Raji May 16 '17 at 11:40