'Jenkins pipeline use variable inside shell and curl
I would like to use a variable inside a curl and shell command, the command is :
sh """\ oc exec pod-test -c "conttest" -- \\ /bin/bash -c 'curl X POST \\ -u "usr:pass" \\ -H "content-Type:application/json" \\ -d "{\"id\": \"1\"} \\ http://127.0.0.1:8080/tym/api/obj/$profile/add"' """.stripIndent()
the variable profile is not replaced correctly and i have this error : command terminated with exit 3
Solution 1:[1]
Be sure you use the right string syntax espacially escaping characters like " and \.
You can use variables in strings like this
"${profile}"
For more information about groovy and strings see https://www.tutorialspoint.com/groovy/groovy_strings.htm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MaGro |
