我是 Groovy 的新手,正在尝试调用 Groovy 脚本作为 Jenkins 构建后操作,但是每当我运行它时,我都会收到“错误:无法评估 groovy 脚本”:
groovy.lang.MissingMethodException:没有方法签名:Script1.stage() 适用于参数类型:(org.codehaus.groovy.runtime.GStringImpl, Script1$_run_closure1) 值:[branch_1, Script1$_run_closure1@7e39737b] 可能的解决方案: wait(), any(), isCase(java.lang.Object) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
这是我的代码:
def warList1= ["one.war", "two.war", "three.war" ]
def branches = [:]
for (int i = 0; i < 10 ; i++) {
int index=i, branch = i+1
stage ("branch_${branch}"){
branches["branch_${branch}"] = {
node {
sshagent(credentials : ['someuser-SSH']){
sh "scp ${WORKSPACE}/${warList1[index]} someuser@<somefqdn>:/tmp/pscp/dev"
}
}
}
}
}
}