Skip to content

Instantly share code, notes, and snippets.

@garethahealy
Created November 7, 2018 15:02
Show Gist options
  • Save garethahealy/f884c75a90d8b53170549479dbc0f7cf to your computer and use it in GitHub Desktop.
Save garethahealy/f884c75a90d8b53170549479dbc0f7cf to your computer and use it in GitHub Desktop.
def generateJinja2DashboardStep(index, openshiftMap) {
echo "$index == $openshiftMap"
openshiftMap.each { project ->
sh """
echo "hello${project}" >> batch${index}.tmp
"""
}
def batchName = "batch${index}"
stash includes: '*.tmp', name: "$batchName"
}
node('maven') {
stage('stepsForParallel') {
script {
def openshiftMap = [0, 1, 2, 3, 4]
def openshiftMapSplit = openshiftMap.collate(2)
echo "openshiftMapSplit = $openshiftMapSplit"
def parallelSteps = [:]
openshiftMapSplit.eachWithIndex { currentMap, index ->
parallelSteps += ["batch${index}": {
node('maven') {
stage("batch${index}") {
generateJinja2DashboardStep(index, currentMap)
}
}
}]
}
parallel parallelSteps
dir("dashboards") {
openshiftMapSplit.eachWithIndex { it2, index ->
unstash "batch${index}"
sh "cat batch${index}.tmp"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment