From 5a81df9561242451745246060e8c271b6c8e3aa8 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 8 Jul 2023 19:51:25 +0200 Subject: Jenkins: add support to specify build node per individual job buildPackage() now has an additional parameter named "buildLabel" that is used to determine/define where a particular job must be executed. This defaults to ec2_amd64 which was always the default. --- vars/buildPackage.groovy | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'vars/buildPackage.groovy') diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy index fa2403e3..936eef0d 100644 --- a/vars/buildPackage.groovy +++ b/vars/buildPackage.groovy @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesPattern="**") { +def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesPattern="**", buildLabel="ec2_amd64") { // - description: Arbitrary text to print on Jenkins Job Description // instead of package name // - pkgList: Multiple packages can be build at once in a single Pipeline run @@ -23,6 +23,9 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP // - buildArm: package will also be build for the arm64 platform // - changesPattern: package will only be build if a change file matching this // pattern is found + // - buildLabel: used to describe where the job should run. amd64 inside the + // string will be replaced with arm64 when those builds are enabled. + // Example: ec2_amd64 -> ec2_arm64 or foo_amd64 -> foo_arm64 setDescription(description) @@ -37,7 +40,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP stages { stage('Define Agent') { agent { - label "ec2_amd64" + label "${buildLabel}" } when { anyOf { @@ -75,7 +78,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP stage('amd64') { agent { docker { - label "ec2_amd64" + label "${buildLabel}" args "${env.DOCKER_ARGS}" image "${env.DOCKER_IMAGE}" alwaysPull true @@ -104,7 +107,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP stage('arm64') { agent { docker { - label "ec2_arm64" + label "${buildLabel.replace('amd64', 'arm64')}" args "${env.DOCKER_ARGS}" image "${env.DOCKER_IMAGE}-arm64" alwaysPull true @@ -136,7 +139,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP } } agent { - label "ec2_amd64" + label "${buildLabel}" } steps { script { -- cgit v1.2.3