Commit b9b93243 authored by Dominik Charousset's avatar Dominik Charousset Committed by Joseph Noir

Flatten pipeline into a single parallel block

parent 7f772be7
...@@ -171,12 +171,14 @@ def buildSteps(buildType, cmakeArgs) { ...@@ -171,12 +171,14 @@ def buildSteps(buildType, cmakeArgs) {
} }
// Builds a stage for given builds. Results in a parallel stage `if builds.size() > 1`. // Builds a stage for given builds. Results in a parallel stage `if builds.size() > 1`.
def makeBuildStage(builds, lblExpr, settings) { def makeBuildStages(matrixIndex, builds, lblExpr, settings) {
if (builds.size() == 1) { builds.collectEntries { buildType ->
def buildType = builds[0] def id = "$matrixIndex $lblExpr: $buildType"
return { [
(id):
{
node(lblExpr) { node(lblExpr) {
stage("$lblExpr: $buildType") { stage(id) {
withEnv(buildEnvironments[lblExpr] ?: []) { withEnv(buildEnvironments[lblExpr] ?: []) {
buildSteps(buildType, settings['cmakeArgs'] ?: '') buildSteps(buildType, settings['cmakeArgs'] ?: '')
(settings['extraSteps'] ?: []).each { fun -> "$fun"() } (settings['extraSteps'] ?: []).each { fun -> "$fun"() }
...@@ -184,15 +186,7 @@ def makeBuildStage(builds, lblExpr, settings) { ...@@ -184,15 +186,7 @@ def makeBuildStage(builds, lblExpr, settings) {
} }
} }
} }
} ]
return {
node('master') {
stage("$lblExpr: Fan Out") {
parallel builds.collectEntries { buildType ->
["$lblExpr: $buildType": makeBuildStage([buildType], lblExpr, settings)]
}
}
}
} }
} }
...@@ -220,15 +214,16 @@ pipeline { ...@@ -220,15 +214,16 @@ pipeline {
stage('Builds') { stage('Builds') {
steps { steps {
script { script {
// Create stages for our building everything in our build // Create stages for building everything in our build matrix in
// matrix in parallel. // parallel.
def xs = [:] def xs = [:]
buildMatrix.eachWithIndex { entry, index -> buildMatrix.eachWithIndex { entry, index ->
def (os, settings) = entry def (os, settings) = entry
settings['tools'].eachWithIndex { tool, toolIndex -> settings['tools'].eachWithIndex { tool, toolIndex ->
def labelExpr = "$os && $tool" def matrixIndex = "[$index:$toolIndex]"
def builds = settings['builds'] def builds = settings['builds']
xs["Build $os [$index:$toolIndex]"] = makeBuildStage(builds, labelExpr, settings) def labelExpr = "$os && $tool"
xs << makeBuildStages(matrixIndex, builds, labelExpr, settings)
} }
} }
parallel xs parallel xs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment