1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/runClosures.groovy

16 lines
586 B
Groovy
Raw Normal View History

void call(script, Map closures, Boolean parallelExecution, String label = "closures") {
handlePipelineStepErrors(stepName: 'runClosures', stepParameters: [script: script]) {
echo "Executing $label"
if (parallelExecution) {
echo "Executing $label in parallel"
parallel closures
} else {
echo "Executing $label in sequence"
def closuresToRun = closures.values().asList()
for (int i = 0; i < closuresToRun.size(); i++) {
(closuresToRun[i] as Closure)()
}
}
}
}