gpt4 book ai didi

linux - 通过 Jenkins : "find: missing argument to ` -exec'"执行 Groovy 命令

转载 作者:太空狗 更新时间:2023-10-29 12:12:39 28 4
gpt4 key购买 nike

我正在尝试使用 Jenkins 管道脚本 (groovy) 将生成的 war 文件从一个构建目录复制到另一个构建目录。我已经作为 jenkins 用户在系统本身上测试了 find/exec/cp 命令,在脚本运行的同一工作区中,它工作正常(直接从控制台复制粘贴)。

String buildNumber = env.BUILD_NUMBER

def sout = new StringBuffer()
def serr = new StringBuffer()

//Create package directory in jenkins job folder
def packageDir = "${env.JENKINS_HOME}/jobs/Package_Deploy_Pipeline/builds/${buildNumber}/package/"
def command = "mkdir ${packageDir}"
def proc = command.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(3000)
println "out> $sout err> $serr"

command = "find ${env.JENKINS_HOME}/jobs/myJob/builds/lastSuccessfulBuild/archive/build/libs/ -name *.war -exec cp {} ${packageDir} \\;"
println command
proc = command.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(3000)
println "out> $sout err> $serr"

在控制台输出中看到的错误是:

[Pipeline] echo
out> err>
[Pipeline] echo
find /var/lib/jenkins/jobs/myJob/builds/lastSuccessfulBuild/archive/build/libs/ -name *.war -exec cp {} /var/lib/jenkins/jobs/Package_Deploy_Pipeline/builds/23/package/ \;
[Pipeline] echo
out> err> find: missing argument to `-exec'

编辑:我也尝试过 "*.war"'*.war'\;'; '

最佳答案

带有声明式管道的 Jenkins 只对我有效:

sh '找到 . -ipath "*src/header.h"-exec rm {} ";"'

关于linux - 通过 Jenkins : "find: missing argument to ` -exec'"执行 Groovy 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37034429/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com