From 9e57b42149d25092d22fd215d4bd08f3cb089c88 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 24 Jul 2021 20:26:57 +0200 Subject: Jenkins: lib: add changesPattern parameter to buildPackage class we can now externally control if the package should be build when a file changes. It defaults to "*" which means "always build". --- vars/buildPackage.groovy | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'vars') diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy index af6740ad..5dc6aeeb 100644 --- a/vars/buildPackage.groovy +++ b/vars/buildPackage.groovy @@ -14,13 +14,15 @@ // 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) { +def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesPattern="**") { // - 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 // - buildCmd: replace default build command "dpkg-buildpackage -uc -us -tc -b" // with this custom version // - 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 setDescription(description) @@ -37,6 +39,12 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false) { agent { label "ec2_amd64" } + when { + anyOf { + changeset pattern: changesPattern, caseSensitive: true + triggeredBy cause: "UserIdCause" + } + } steps { script { // create container name on demand @@ -57,6 +65,12 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false) { } } stage('Build Code') { + when { + anyOf { + changeset pattern: changesPattern, caseSensitive: true + triggeredBy cause: "UserIdCause" + } + } parallel { stage('amd64') { agent { @@ -110,6 +124,12 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false) { } } stage("Finalize") { + when { + anyOf { + changeset pattern: changesPattern, caseSensitive: true + triggeredBy cause: "UserIdCause" + } + } agent { label "ec2_amd64" } -- cgit v1.2.3