jenkins - 错误:Jenkins Groovy脚本中的 “Expected named arguments”并行

标签 jenkins groovy jenkins-pipeline jenkins-2

我有一个Jenkins 2.0管道,带有这样的groovyscript:

node('nnh561.raijin') {
    stage 'checkout'
    build('trunk/checkout')

    stage 'build'
    parallel(
        { build('trunk/build/gfortran') },
        { build('trunk/build/ifort') }
    )

}

每个单独的工作都可以正常运行,但是当我尝试运行管道时,遇到并行步骤时,它会吐出此错误:
java.lang.IllegalArgumentException: Expected named arguments but got [org.jenkinsci.plugins.workflow.cps.CpsClosure2@242d0d3a, org.jenkinsci.plugins.workflow.cps.CpsClosure2@9bf6d64]
    at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:275)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:110)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113)
    at groovy.lang.GroovyObject$invokeMethod$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
    at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
    at WorkflowScript.run(WorkflowScript:6)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
    at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:40)
    at com.cloudbees.groovy.cps.Next.step(Next.java:58)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:277)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:77)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:186)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:184)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

任何想法可能会导致类似的事情吗?

最佳答案

啊...管道需要一个 map ,而不是列表。命名参数有效:

node('nnh561.raijin') {
    stage 'checkout'{
    build('trunk/checkout')}

    stage 'build'
    parallel (
        'gfortran': { build('trunk/build/gfortran') },
        'ifort': { build('trunk/build/ifort') }
    )
}

关于jenkins - 错误:Jenkins Groovy脚本中的 “Expected named arguments”并行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36931114/

相关文章:

http - 如何更改 OpenShift Jenkins 以使用 HTTP 而不是 HTTPs

android - 如何从 jenkins 作业生成 android 应用程序包

ant - Sonar 插件不适用于使用 ANT 作为构建脚本的项目

groovy - 如何从 Groovy 设置 JIRA 票证的版本字段

jenkins-pipeline - 当管道名称以交付结束时,如何跳过 Jenkinsfile 管道中的一个阶段?

apache - 将 URL 前缀添加到 Jenkins 服务器配置

json - 如何从Windows从属设备上的groovy文件运行复杂的curl命令(使用json)

java - 在两个标签之间以常规方式解析?

visual-studio - 无法加载项目文件。缺少根元素

python - 使用 Jenkins 中的管道执行 pytest