我正在创建一个Pipeline Parallel suite作业,它将使用传递的参数触发其他独立作业。但是管道在执行后抛出了非法的参数异常。使用的代码是将4个参数传递给创建的作业并放在同一文件夹下。
使用的脚本:
node{
environment_url=DeploymentEnvmt
BrowserName=Browse
parallel (
{
build job: 'test_job', parameters: [[$class: 'StringParameterValue',name: 'baseUrlFromDeploymentJob', value: "$environment_url"],[$class: 'StringParameterValue', name: 'dynamicHubUrlTarget', value: "http://test.x.x.x/wd/hub"],[$class: 'StringParameterValue', name: 'reDirectHubUrlVal', value: "yes"],[$class: 'StringParameterValue', name: 'Browser', value: "$BrowserName"]] })
例外:
java.lang.IllegalArgumentException: Expected named arguments but got org.jenkinsci.plugins.workflow.cps.CpsClosure2@d78a0b
at org.jenkinsci.plugins.workflow.cps.DSL.singleParam(DSL.java:542)
at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:530)
at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:470)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:183)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
at sun.reflect.GeneratedMethodAccessor493.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
请帮助解决非法参数异常错误。需要针对语法进行纠正的内容
它必须是Map<String, Closure>
,而不是封闭。 This将对您有所帮助。
parallel(
build(
job: 'test_job',
parameters:
[[$class: 'StringParameterValue', name: 'baseUrlFromDeploymentJob', value: "$environment_url"],
[$class: 'StringParameterValue', name: 'dynamicHubUrlTarget', value: "http://test.x.x.x/wd/hub"],
[$class: 'StringParameterValue', name: 'reDirectHubUrlVal', value: "yes"],
[$class: 'StringParameterValue', name: 'Browser', value:
"$BrowserName"]
]
)
)
您还可以简化您的parameters
地图:
parallel(
build(
job: 'test_job',
parameters: [
string(name: 'baseUrlFromDeploymentJob', value: "$environment_url"),
string(name: 'dynamicHubUrlTarget', value: "http://test.x.x.x/wd/hub"),
string(name: 'reDirectHubUrlVal', value: "yes"),
string(name: 'Browser', value: "$BrowserName")
]
)
)
附:感谢@mkobit的纠正。