繁体   English   中英

如何解决-Jenkins生成后操作Groovy脚本无法评估

[英]How to Fix — Jenkins Post-build Action Groovy script fails to evaluate

我是Groovy的新手,正尝试作为Jenkins生成后操作调用Groovy脚本,但是每当运行它时,我都会收到“错误:无法评估groovy脚本”:

groovy.lang.MissingMethodException:方法的无签名:Script1.stage()适用于参数类型:(org.codehaus.groovy.runtime.GStringImpl,Script1 $ _run_closure1)值:[branch_1,Script1 $ _run_closure1 @ 7e39737b]可能的解决方案:org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap上的wait(),any(),isCase(java.lang.Object)(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"
                    }
                }     
            }
        }
    }
}

我认为您的问题源于您无法在Groovy Post Build Action中使用stage方法的事实。 此方法仅在管道脚本中可用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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