[英]How to use shell script variable as groovy variable in Jenkins pipeline script
[英]Jenkins pipeline use variable inside shell and curl
我想在 curl 和 shell 命令中使用一个变量,命令是:
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()
变量配置文件没有被正确替换,我有这个错误:命令以退出 3 终止
请务必使用正确的字符串语法,特别是 escaping 个字符,例如"
和\
。您可以在字符串中使用变量,例如"${profile}"
有关 groovy 和字符串的更多信息,请参阅https://www.tutorialspoint.com/groovy/groovy_strings.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.