From d02450f6234bd79e58b961c8ca2bfb85a01ec1c2 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 27 Aug 2021 10:20:46 +0200 Subject: Jenkins: lib: specify when { beforeAgent true } By default, the when condition for a stage will be evaluated after entering the agent for that stage, if one is defined. However, this can be changed by specifying the beforeAgent option within the when block. If beforeAgent is set to true, the when condition will be evaluated first, and the agent will only be entered if the when condition evaluates to true. --- vars/buildPackage.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy index 9517a79f..2b16c472 100644 --- a/vars/buildPackage.groovy +++ b/vars/buildPackage.groovy @@ -40,6 +40,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP label "ec2_amd64" } when { + beforeAgent true anyOf { changeset pattern: changesPattern, caseSensitive: true changeset pattern: "**/data/defaults.json", caseSensitive: true @@ -67,6 +68,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP } stage('Build Code') { when { + beforeAgent true anyOf { changeset pattern: changesPattern, caseSensitive: true triggeredBy cause: "UserIdCause" @@ -126,6 +128,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP } stage("Finalize") { when { + beforeAgent true anyOf { changeset pattern: changesPattern, caseSensitive: true triggeredBy cause: "UserIdCause" -- cgit v1.2.3