不确定这是我对Groovy的有限了解还是管道parallel
步骤中的怪癖。如果我使用map而不是单独传递每个闭包,我无法接受failFast
:
def map = [:]
map['spam'] = {
node {
echo 'spam'
}
}
map['eggs'] = {
node {
echo 'eggs'
}
}
parallel map // Works.
parallel spam: map['spam'], eggs: map['eggs'], failFast: true // Works.
parallel map, failFast: true // Fails with exception.
failFast
的例外是:
java.lang.IllegalArgumentException: Expected named arguments but got [{failFast=true}, {spam=org.jenkinsci.plugins.workflow.cps.CpsClosure2@51a382ad, eggs=org.jenkinsci.plugins.workflow.cps.CpsClosure2@718cb50d}]
at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:276)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:111)
答案 0 :(得分:23)
map.failFast = true
parallel map
答案 1 :(得分:1)
如果添加可选语法,它会有所帮助。第二个选项是传递新的Map
,而第三个选项传递原始Map
和另一个命名参数。老实说,我不确定它的想法是什么。
parallel(map)
parallel([
spam: map['spam'],
eggs: map['eggs'],
failFast: true
])
parallel map, failFast: true
无论如何,我认为最简单的事情就是:
def map = [
spam: {
node {
echo 'spam'
}
},
eggs: {
node {
echo 'eggs'
}
},
failFast: true
]
parallel map
...或
parallel ([
spam: {
node {
echo 'spam'
}
},
eggs: {
node {
echo 'eggs'
}
},
failFast: true
])
答案 2 :(得分:0)