summaryrefslogtreecommitdiff
path: root/vars
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-06-27 14:57:18 +0200
committerChristian Poessinger <christian@poessinger.com>2020-06-27 14:57:18 +0200
commit2e1e117f96674b6bdbcf51cc62ef5345c6a1509d (patch)
tree8893ceca844b07a0ce29abe26c2cd5dacc36f5b3 /vars
parente68de0e41fe7bfdee4fddf5f42e3404da09f2bf6 (diff)
downloadvyos-build-2e1e117f96674b6bdbcf51cc62ef5345c6a1509d.tar.gz
vyos-build-2e1e117f96674b6bdbcf51cc62ef5345c6a1509d.zip
Jenkins: lib: T2625: support PullRequest builds
Diffstat (limited to 'vars')
-rw-r--r--vars/buildPackage.groovy7
-rw-r--r--vars/isCustomBuild.groovy2
-rw-r--r--vars/isPullRequest.groovy21
3 files changed, 25 insertions, 5 deletions
diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy
index edd854b7..463170e6 100644
--- a/vars/buildPackage.groovy
+++ b/vars/buildPackage.groovy
@@ -35,10 +35,8 @@ def call(description=null, pkgList=null, buildCmd=null) {
script {
// create container name on demand
def branchName = getGitBranchName()
- // Adjust PR target branch name so we can re-map it to the proper
- // Docker image. CHANGE_ID is set only for pull requests, so it is
- // safe to access the pullRequest global variable
- if (env.CHANGE_ID) {
+ // Adjust PR target branch name so we can re-map it to the proper Docker image.
+ if (isPullRequest()) {
branchName = "${env.CHANGE_TARGET}".toLowerCase()
}
if (branchName.equals("master")) {
@@ -106,6 +104,7 @@ def call(description=null, pkgList=null, buildCmd=null) {
beforeAgent true
anyOf {
changeset pattern: "${env.CHANGESET_DIR}"
+ expression { isPullRequest() }
triggeredBy 'TimerTrigger'
triggeredBy cause: "UserIdCause"
}
diff --git a/vars/isCustomBuild.groovy b/vars/isCustomBuild.groovy
index 301fdd42..c5e5fab7 100644
--- a/vars/isCustomBuild.groovy
+++ b/vars/isCustomBuild.groovy
@@ -22,5 +22,5 @@ def call() {
def gitURI = 'git@github.com:vyos/' + getGitRepoName()
def httpURI = 'https://github.com/vyos/' + getGitRepoName()
- return !((getGitRepoURL() == gitURI) || (getGitRepoURL() == httpURI)) || env.CHANGE_ID
+ return !((getGitRepoURL() == gitURI) || (getGitRepoURL() == httpURI)) || isPullRequest()
}
diff --git a/vars/isPullRequest.groovy b/vars/isPullRequest.groovy
new file mode 100644
index 00000000..813341bc
--- /dev/null
+++ b/vars/isPullRequest.groovy
@@ -0,0 +1,21 @@
+// 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 <http://www.gnu.org/licenses/>.
+
+def call() {
+ if (env.CHANGE_ID) {
+ return true
+ }
+ return false
+}