how to achieve Concurrency with groovy script used in freestyleproject

6 views
Skip to first unread message

Sivakumar Durairaj

unread,
Jan 6, 2020, 7:18:52 PM1/6/20
to Jenkins Users
Hi All,


Can please help me on how to achieve concurrency using groovy script in Jenkins freestyleproject?.

I have tried to execute below script. But I am getting the following error "Caught: groovy.lang.MissingMethodException: No signature of method: main.parallel() is applicable for argument types: (java.util.LinkedHashMap) values: [[job1:main$_run_closure1$_closure2@776aec5c, job2:main$_run_closure1$_closure2@1d296da, ...]]
groovy.lang.MissingMethodException: No signature of method: main.parallel() is applicable for argument types: (java.util.LinkedHashMap) values: [[job1:main$_run_closure1$_closure2@776aec5c, job2:main$_run_closure1$_closure2@1d296da, ...]]
at main.run(main.groovy:23)" Script def jobsString = "job1,job2,job3"
ArrayList jobsList = jobsString.split('\\,')

def parallelJobs2Run = [:]
jobsList
.each { job ->
    echo
"Going to parallel for job ${job}"
    parallelJobs2Run
["${job}"] = { ->
        echo
"Calling job ${job}"
        jobResults
=build job: "${pathJenkinsFolder}${job}",
        parameters
: [
           
string(name: 'param1', value: "${value1}"),
           
string(name: 'param2', value: "${value2}")
       
],
        propagate
: true,
        wait
: true

        buildNumber
= ${jobResults.number}
        echo
"${job} Build number |${buildNumber}| result: |${jobResults.result}|"
        echo
"See details on: |${jobResults.absoluteUrl}|"
   
}
};
parallel parallelJobs2Run



Reply all
Reply to author
Forward
0 new messages