Created
April 12, 2017 04:47
-
-
Save visitbethel/dcc2c0a8bc9b76859baf7bb4939e029d to your computer and use it in GitHub Desktop.
Parallel Execution of a list of selected Pipelines on different "Streets" to create a workflow.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
echo "STEPS : ${STEPS}" | |
//echo "name : ${name}" | |
def streets = ['STREET_1','STREET_2','STREET_3'] | |
def execution_map = [:] | |
for (int j=0; j < streets.size(); j++) { | |
for (int i=0; i < STEPS.length; i++) { | |
if ( streets[j] == STEPS[i].BUILD_STREET ) { | |
if (execution_map.get(streets[j]) == null) { | |
execution_map.put(streets[j], []) | |
} | |
def a = execution_map.get(streets[j]) | |
a.add(STEPS[i].BUILD_STEP) | |
} | |
echo "\u25B6 - ${STEPS[i].BUILD_STEP.fullName}" | |
} | |
} | |
//echo "execution map : ${execution_map}" | |
for (int j=0; j < streets.size(); j++) { | |
if (execution_map.get(streets[j])) { | |
def key = streets[j] | |
def value = execution_map[key] | |
execution_list = [:] | |
for (int i=0; i < value.size();i++) { | |
echo "${value[i]}" | |
execution_list["${key}-job-${i}"]= this.getJobForStreet(value[i],i) | |
} | |
parallel execution_list | |
} | |
} | |
def Closure getJobForStreet(jobName, int index) { | |
def jobpath = "${jobName.fullName}".split("/") | |
return { | |
stage("\u2714 ${jobpath[jobpath.length-2]}-${index}") { | |
build job: jobName.fullName | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment