Jenkins: lib: T2625: support PullRequest builds

This commit is contained in:
Christian Poessinger 2020-06-27 14:57:18 +02:00
parent e68de0e41f
commit 2e1e117f96
3 changed files with 25 additions and 5 deletions

View File

@ -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"
}

View File

@ -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()
}

21
vars/isPullRequest.groovy Normal file
View File

@ -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
}