Search code examples
jenkinsgroovyjenkins-workflowjenkins-pipeline

Using failFast with closure map breaks "parallel" step


Not sure if it's my limited knowledge of Groovy or a quirk in Pipeline parallel step. I can't make it accept failFast if I use map instead of passing each closure individually:

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.

The exception with failFast is:

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)

Solution

  • map.failFast = true
    parallel map