Sreevalsa E
Sreevalsa E

Reputation: 986

"java.lang.IllegalArgumentException: Expected a closure or failFast" Exception on running parallel builds

I have a pipeline which has two parallel run in sequence. Setup in many slaves in parallel and after all the machine setup is done I have a Build and run stage as coded below. But when I tried running the script I am getting error java.lang.IllegalArgumentException: Expected a closure or failFast but found 0=org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper. Code for reference:

def slaves = params.slaves

stage('Setup'){
    for(int i=0; i<slaves.size(); ++i){
        def slave = slaves[i]
        setup_builds[i] = build job: 'setup', parameters: [[$class: 'LabelParameterValue', name: 'TestMachine', label: slave]]
    }
    parallel setup_builds
}
stage('Build, run) {
    for (int i = 0; i < 4; ++i){
        def index = i
        builds[i] = {
            stage('Build') {
                build job: 'Build'
            }

            stage('Run') {
               build job: 'Run', parameters: [string(name: 'index', value: index)]
            }
        }
    }

    parallel builds
}

I have tried using setup_builds.failFast = true and builds.failFast = true before parallel setup_builds and parallel builds. But even that didn't fix the issue.

Upvotes: 4

Views: 4036

Answers (1)

hakamairi
hakamairi

Reputation: 4678

I think one of the issues is that it expects a closure on the setup_builds level:

setup_builds[i] =  { build job: 'setup' ... }

Upvotes: 5

Related Questions