Context: I have a long dynamic list of builds calls that I am currently executing in parallel successfully. Example below.
Problem: In some specific moments it is required to run that list of builds but in a sequential fashion.
Question: Is there any way to reuse the list of jobs that I already have generated for the parallel execution, but to execute them in a sequential way?
stage ('Execute jobs') {
steps {
node('node1') {
script {
parallel_jobs = [:]
if (params.includeJob1 == "true") {
parallel_jobs['ci'] = {
build job: job1, parameters: [], propagate: true
}
}
parallel_jobs['second'] = {
build job: job2, parameters: [], propagate: true
}
// ...
// and more jobs dinamically added to the parallel_jobs list
// ... parallel_jobs['etc'] = ...
parallel parallel_jobs
}
}
}
}
I am thinking to replace the 'parallel' call for any other Jenkins command, but cannot find the correct one at docs (https://www.jenkins.io/doc/book/pipeline/syntax/#parallel).
Thank you.