我正在使用Jenkins在
linux机器上启动脚本.
当我在服务器上手动运行它时,它可以工作:
/ bin / bash -c’/ some / script MyProduct SomeBranch’
当我用groovy运行它时,它不起作用.
我得到了同样的错误,好像我没有传递“-c”选项,所以不知何故“-c”不起作用.
这是我的代码:
branchName = "SomeBranch"
configName = "release"
println "Building for branch "+branchName+" and configuration "+configName
def chkbranch = { String product,String branch -> mkcmd( product,branch ) }
private def mkcmd ( String product,String branch ) {
// Build the command string to run
def cmd = "/bin/bash -c '/some/script "+product+" "+branch+"'"
def sout = new StringBuffer()
def serr = new StringBuffer()
// Run the command
println "running "+cmd
def proc = cmd.execute()
proc.consumeProcessOutput ( sout,serr )
proc.waitForProcessOutput ()
println "out> $sout"
println "err> $serr"
return sout
}
chkbranch ( "MyProduct",branchName )
这是在Groovy中构建命令的正确方法吗?:
def cmd = "/bin/bash -c '/some/script "+product+" "+branch+"'"
cmd.execute()
谢谢!
我试过类似/有用资源的问题: