简体   繁体   中英

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.

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:

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.

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 """.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM