[英]Need to Run Bash commands in groovy Jenkins script
While running this Bash command in an sh """
block I am getting an error in the below Groovy Jenkins code.在sh """
块中运行此 Bash 命令时,我在以下 Groovy Jenkins 代码中遇到错误。
I am getting this error:我收到此错误:
/home/jenkins/workspace/_api-build_features_SSSVCS-12870@tmp/durable-be642e71/script.sh: line 1: syntax error: unterminated quoted string
for the below 2 lines of Groovy code:对于下面两行 Groovy 代码:
aa = sh(script: "aa=\"\$(helm2 version --short --client|awk '{print substr(\$2,1,2)}'\"; echo \$aa", returnStdout: true).trim()
I am using the variable aa in below if then else loop, Please suggest me.我在下面使用变量 aa if then else 循环,请建议我。
sh """
if [ aa == v2 ]; then
helm package --save=false ${extraArgs} ${PROJ}
else
helm package ${PROJ}
fi
sh """
In the first line, you miss a closing the bracket ')'.在第一行中,您错过了右括号')'。 In the second block, consider removing the second sh, otherwise will be part of the whole string between the two """.在第二个块中,考虑去掉第二个sh,否则会是整个字符串的一部分在两个"""之间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.