From e05f59a7ddcfee39c04d8f95bfb04031210c6471 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 23 Jun 2020 19:14:42 +0200 Subject: Jenkins: lib: T2625: add getChangeSetPath() function Retrieve the path where git should check for modified files to trigger the pipeline build or not. --- vars/buildPackage.groovy | 14 ++------------ vars/getChangeSetPath.groovy | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 vars/getChangeSetPath.groovy (limited to 'vars') diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy index f0435a6f..35f0784c 100644 --- a/vars/buildPackage.groovy +++ b/vars/buildPackage.groovy @@ -59,7 +59,7 @@ def call(description=null, pkgList=null, buildCmd=null) { environment { // get relative directory path to Jenkinsfile BASE_DIR = getJenkinsfilePath() - CHANGESET_DIR = "**/${env.BASE_DIR}*" + CHANGESET_DIR = getChangeSetPath() DEBIAN_ARCH = sh(returnStdout: true, script: 'dpkg --print-architecture').trim() } options { @@ -69,15 +69,6 @@ def call(description=null, pkgList=null, buildCmd=null) { } stages { stage('Fetch Source') { - when { - beforeOptions true - beforeAgent true - anyOf { - changeset "${env.CHANGESET_DIR}" - triggeredBy 'TimerTrigger' - triggeredBy cause: "UserIdCause" - } - } steps { script { // package build must be done in "any" subdir. Without it the Debian build system @@ -114,7 +105,7 @@ def call(description=null, pkgList=null, buildCmd=null) { beforeOptions true beforeAgent true anyOf { - changeset "${env.CHANGESET_DIR}" + changeset pattern: "${env.CHANGESET_DIR}" triggeredBy 'TimerTrigger' triggeredBy cause: "UserIdCause" } @@ -180,7 +171,6 @@ def call(description=null, pkgList=null, buildCmd=null) { if (env.DEBIAN_ARCH != 'all') ARCH_OPT = '-A ' + env.DEBIAN_ARCH - sh "pwd; ls -al" files = findFiles(glob: '*.deb') if (files) { echo "Uploading package(s) and updating package(s) in the repository ..." diff --git a/vars/getChangeSetPath.groovy b/vars/getChangeSetPath.groovy new file mode 100644 index 00000000..f046d7cc --- /dev/null +++ b/vars/getChangeSetPath.groovy @@ -0,0 +1,25 @@ +#!/usr/bin/env groovy +// Copyright (C) 2020 VyOS maintainers and contributors +// +// This program is free software; you can redistribute it and/or modify +// in order to easy exprort images built to "external" world +// it under the terms of the GNU General Public License version 2 or later as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +def call() { + tmp = getJenkinsfilePath() + if (tmp) + tmp = "**/" + tmp + "*" + else + tmp = "**/*" + return tmp +} + -- cgit v1.2.3