summaryrefslogtreecommitdiff
path: root/vars
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-06-05 09:55:27 +0200
committerChristian Poessinger <christian@poessinger.com>2021-06-05 10:06:30 +0200
commit8a6a04fe78dfea724aa807af8911f7210562e59a (patch)
tree0ea487b6230b7953c3c12fec6aaa2ff5c73c05ad /vars
parentff5df7189b8913c227695ee738198c90e0028b01 (diff)
downloadvyos-build-8a6a04fe78dfea724aa807af8911f7210562e59a.tar.gz
vyos-build-8a6a04fe78dfea724aa807af8911f7210562e59a.zip
Jenkins: re-add erroneously removed when build conditions
Debian packages should only be build if a file in the requested subfolder changes (like a version upgrade) or if explicitly reuested by the user. VyOS ISO generation should only be run once a night by the CI if triggered by the timer, or on explicit user request.
Diffstat (limited to 'vars')
-rw-r--r--vars/buildPackage.groovy14
-rw-r--r--vars/cloneAndBuild.groovy134
2 files changed, 76 insertions, 72 deletions
diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy
index ca901481..fde5e59a 100644
--- a/vars/buildPackage.groovy
+++ b/vars/buildPackage.groovy
@@ -37,11 +37,6 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false) {
agent {
label "ec2_amd64"
}
- environment {
- // get relative directory path to Jenkinsfile
- BASE_DIR = getJenkinsfilePath()
- CHANGESET_DIR = getChangeSetPath()
- }
steps {
script {
// create container name on demand
@@ -62,6 +57,15 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false) {
}
}
stage('Build Code') {
+ when {
+ beforeOptions true
+ beforeAgent true
+ anyOf {
+ changeset pattern: getChangeSetPath()
+ expression { isPullRequest() }
+ triggeredBy cause: "UserIdCause"
+ }
+ }
parallel {
stage('amd64') {
agent {
diff --git a/vars/cloneAndBuild.groovy b/vars/cloneAndBuild.groovy
index 0fc847f4..adb62525 100644
--- a/vars/cloneAndBuild.groovy
+++ b/vars/cloneAndBuild.groovy
@@ -1,67 +1,67 @@
-#!/usr/bin/env groovy
-// Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
-
-def call(description, architecture, pkgList, buildCmd) {
- // package build must be done in "any" subdir. Without it the Debian build system
- // is unable to generate the *.deb files in the sources parent directory, which
- // will cause a "Permission denied" error.
- dir ("build-${architecture}") {
- // cleanup
- deleteDir()
-
- // checkout git repository which hold 'Jenkinsfile'
- checkout scm
-
- // Display Git commit Id used with the Jenkinsfile on the Job "Build History" pane
- def commitId = sh(returnStdout: true, script: 'git rev-parse --short=11 HEAD').trim()
- currentBuild.description = sprintf('Git SHA1: %s', commitId[-11..-1])
-
- if (pkgList) {
- // Fetch individual package source code, but only if a URL is defined, this will
- // let us reuse this script for packages like vyos-1x which ship a Jenkinfile in
- // their repositories root folder.
- pkgList.each { pkg ->
- if (pkg.scmUrl && pkg.scmCommit) {
- dir(env.BASE_DIR + pkg.name) {
- checkout([$class: 'GitSCM',
- doGenerateSubmoduleConfigurations: false,
- extensions: [[$class: 'CleanCheckout']],
- branches: [[name: pkg.scmCommit]],
- userRemoteConfigs: [[url: pkg.scmUrl]]])
- }
- }
- }
- }
-
- // compile the source(s) ...
- if (pkgList) {
- pkgList.each { pkg ->
- dir(env.BASE_DIR + pkg.name) {
- sh pkg.buildCmd
- }
- }
- } else if (buildCmd) {
- sh buildCmd
- } else {
- sh 'dpkg-buildpackage -uc -us -tc -b'
- }
- }
- if (architecture == 'amd64') {
- archiveArtifacts artifacts: "**/*.deb", fingerprint: true
- } else {
- archiveArtifacts artifacts: "**/*_${architecture}.deb", fingerprint: true
- }
-}
+#!/usr/bin/env groovy
+// Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
+
+def call(description, architecture, pkgList, buildCmd) {
+ // package build must be done in "any" subdir. Without it the Debian build system
+ // is unable to generate the *.deb files in the sources parent directory, which
+ // will cause a "Permission denied" error.
+ dir ("build-${architecture}") {
+ // cleanup
+ deleteDir()
+
+ // checkout git repository which hold 'Jenkinsfile'
+ checkout scm
+
+ // Display Git commit Id used with the Jenkinsfile on the Job "Build History" pane
+ def commitId = sh(returnStdout: true, script: 'git rev-parse --short=11 HEAD').trim()
+ currentBuild.description = sprintf('Git SHA1: %s', commitId[-11..-1])
+
+ if (pkgList) {
+ // Fetch individual package source code, but only if a URL is defined, this will
+ // let us reuse this script for packages like vyos-1x which ship a Jenkinfile in
+ // their repositories root folder.
+ pkgList.each { pkg ->
+ if (pkg.scmUrl && pkg.scmCommit) {
+ dir(getJenkinsfilePath() + pkg.name) {
+ checkout([$class: 'GitSCM',
+ doGenerateSubmoduleConfigurations: false,
+ extensions: [[$class: 'CleanCheckout']],
+ branches: [[name: pkg.scmCommit]],
+ userRemoteConfigs: [[url: pkg.scmUrl]]])
+ }
+ }
+ }
+ }
+
+ // compile the source(s) ...
+ if (pkgList) {
+ pkgList.each { pkg ->
+ dir(getJenkinsfilePath() + pkg.name) {
+ sh pkg.buildCmd
+ }
+ }
+ } else if (buildCmd) {
+ sh buildCmd
+ } else {
+ sh 'dpkg-buildpackage -uc -us -tc -b'
+ }
+ }
+ if (architecture == 'amd64') {
+ archiveArtifacts artifacts: "**/*.deb", fingerprint: true
+ } else {
+ archiveArtifacts artifacts: "**/*_${architecture}.deb", fingerprint: true
+ }
+}