From 50cdd75f2d3cc62e8f4550bbeb0326b1c6181e3d Mon Sep 17 00:00:00 2001 From: Martin Hierholzer <martin.hierholzer@desy.de> Date: Tue, 2 Oct 2018 16:04:15 +0200 Subject: [PATCH] try generating the parallel jobs from a list --- vars/buildTestDeploy.groovy | 106 +++++++++++------------------------- 1 file changed, 32 insertions(+), 74 deletions(-) diff --git a/vars/buildTestDeploy.groovy b/vars/buildTestDeploy.groovy index 82dbb04..6dcfa7d 100644 --- a/vars/buildTestDeploy.groovy +++ b/vars/buildTestDeploy.groovy @@ -32,6 +32,17 @@ ***********************************************************************************************************************/ +def builds = [ 'xenial-Debug', + 'xenial-Release', + 'bionic-Debug', + 'bionic-Release', + 'tumbleweed-Debug', + 'tumbleweed-Release' ] + + +/**********************************************************************************************************************/ + +// This is the function called from the .jenkinsfile def call(ArrayList<String> dependencyList) { pipeline { @@ -40,80 +51,7 @@ def call(ArrayList<String> dependencyList) { stage('build') { // Run the build stages for all labels + build types in parallel, each in a separate docker container // Note: If the list of labels + build types is extended here, don't forget to update also the doPublish() function! - parallel { - stage('Ubuntu 16.04 Release') { - agent { - docker { - image "builder:xenial" - // we need root access inside the container and access to the dummy pcie devices of the host - args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" - } - } - steps { - doAll(dependencyList, "Ubuntu1604", "Release") - } - } - stage('Ubuntu 16.04 Debug') { - agent { - docker { - image "builder:xenial" - // we need root access inside the container and access to the dummy pcie devices of the host - args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" - } - } - steps { - doAll(dependencyList, "Ubuntu1604", "Debug") - } - } - stage('Ubuntu 18.04 Release') { - agent { - docker { - image "builder:bionic" - // we need root access inside the container and access to the dummy pcie devices of the host - args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" - } - } - steps { - doAll(dependencyList, "Ubuntu1804", "Release") - } - } - stage('Ubuntu 18.04 Debug') { - agent { - docker { - image "builder:bionic" - // we need root access inside the container and access to the dummy pcie devices of the host - args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" - } - } - steps { - doAll(dependencyList, "Ubuntu1804", "Debug") - } - } - stage('SUSE Tumbeweed Release') { - agent { - docker { - image "builder:tumbleweed" - // we need root access inside the container and access to the dummy pcie devices of the host - args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" - } - } - steps { - doAll(dependencyList, "SUSEtumbleweed", "Release") - } - } - stage('SUSE Tumbeweed Debug') { - agent { - docker { - image "builder:tumbleweed" - // we need root access inside the container and access to the dummy pcie devices of the host - args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" - } - } - steps { - doAll(dependencyList, "SUSEtumbleweed", "Debug") - } - } - } // end parallel + parallel builds.collectEntries { ["${it}" : transformIntoStep(dependencyList, it)] } } // end stage build } // end stages post { @@ -128,6 +66,26 @@ def call(ArrayList<String> dependencyList) { /**********************************************************************************************************************/ +def transformIntoStep(ArrayList<String> dependencyList, String buildName) { + // split the build name at the '-' + def (label, buildType) = buildName.tokenize('-') + // we need to return a closure here, which is then passed to parallel() for execution + return { + agent { + docker { + image "builder:${label}" + // we need root access inside the container and access to the dummy pcie devices of the host + args "-u 0 --device=/dev/mtcadummys0 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6" + } + } + steps { + doAll(dependencyList, label, buildType) + } + } +} + +/**********************************************************************************************************************/ + def doAll(ArrayList<String> dependencyList, String label, String buildType) { // Add inactivity timeout of 10 minutes (build will be interrupted if 30 minutes no log output has been produced) -- GitLab