小编典典

将failFast与闭包映射一起使用可打破“并行”步骤

jenkins

不知道这是我对Groovy的有限了解还是Pipeline
parallel步骤中的怪癖。failFast如果我使用map而不是单独传递每个闭包,则无法接受它:

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)

阅读 328

收藏
2020-07-25

共1个答案

小编典典

map.failFast = true
parallel map
2020-07-25