message: Flatten pipeline into a single parallel block
diff: @@ -171,12 +171,14 @@ def buildSteps(buildType, cmakeArgs) {
  }
  // Builds a stage for given builds. Results in a parallel stage `if builds.size() > 1`.
  -def makeBuildStage(builds, lblExpr, settings) {
  - if (builds.size() == 1) {
  - def buildType = builds[0]
  - return {
  +def makeBuildStages(matrixIndex, builds, lblExpr, settings) {
  + builds.collectEntries { buildType ->
  + def id = "$matrixIndex $lblExpr: $buildType"
  + [
  + (id):
  + {
  node(lblExpr) {
  - stage("$lblExpr: $buildType") {
  + stage(id) {
  withEnv(buildEnvironments[lblExpr] ?: []) {
  buildSteps(buildType, settings['cmakeArgs'] ?: '')
  (settings['extraSteps'] ?: []).each { fun -> "$fun"() }
  @@ -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 {
  stage('Builds') {
  steps {
  script {
  - // Create stages for our building everything in our build
  - // matrix in parallel.
  + // Create stages for building everything in our build matrix in
  + // parallel.
  def xs = [:]
  buildMatrix.eachWithIndex { entry, index ->
  def (os, settings) = entry
  settings['tools'].eachWithIndex { tool, toolIndex ->
  - def labelExpr = "$os && $tool"
  + def matrixIndex = "[$index:$toolIndex]"
  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
  