当'&'是URL的一部分时,Jenkins管道中的sh步骤失败

时间:2019-03-04 11:05:30

标签: jenkins-pipeline

我需要从Nexus下载工件,并且正在使用wget并从管道的sh资源中调用它

def artifact_url = nexus_url + '?r=company-group&g=com.oa&a=test&v=' + version + '&p=war'
sh (script : "wget ${artifact_url} -O earfile.ear")

上述代码失败,因为管道无法将任何内容附加到前面带有“&”号的URL。错误的输出在下面给出

[V2_DEPLOY] Running shell script
+ g=com.oa
+ a=earapp
+ p=war
+ -O earfile.ear
+ v=99.005.08-SNAPSHOT
+ wget 'https://nexus/nexus/service/local/artifact/maven/redirect?r=group-repo'
/WORKSPACE PATH/script.sh: line 2: -O: command not found

1 个答案:

答案 0 :(得分:0)

在将网址用单引号引起来之后解决

sh (script : "wget '${artifact_url}' -O earfile.ear")