Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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.

like image 579
Sreevalsa E Avatar asked Oct 29 '25 02:10

Sreevalsa E


1 Answers

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

setup_builds[i] =  { build job: 'setup' ... }
like image 187
hakamairi Avatar answered Oct 31 '25 17:10

hakamairi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!