summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerard Ryan <gerard@ryan.lt>2017-08-29 13:32:47 +0100
committerKien Ha <kienha9922@gmail.com>2018-07-03 18:26:27 -0400
commit70f7ef229104e5f61afb48af9395cbdf94b57a9e (patch)
tree088e535fd0fd202248b0e886cd12c3665d21fa48
parent637676375a719a60205615ce407bee568b6051ab (diff)
downloadpython-jenkins-job-builder-70f7ef229104e5f61afb48af9395cbdf94b57a9e.tar.gz
python-jenkins-job-builder-70f7ef229104e5f61afb48af9395cbdf94b57a9e.tar.xz
python-jenkins-job-builder-70f7ef229104e5f61afb48af9395cbdf94b57a9e.zip
ghprb: blacklist-target-branches support
Change-Id: I27f49f25d97c810904cb107042380b9e7bb7fd42 Co-Authored-By: Kien Ha <kienha9922@gmail.com> Signed-off-by: Kien Ha <kienha9922@gmail.com>
-rw-r--r--jenkins_jobs/modules/triggers.py12
-rw-r--r--tests/triggers/fixtures/github-pull-request-full.xml8
-rw-r--r--tests/triggers/fixtures/github-pull-request-full.yaml3
3 files changed, 23 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py
index cf7db989..4a0f11ab 100644
--- a/jenkins_jobs/modules/triggers.py
+++ b/jenkins_jobs/modules/triggers.py
@@ -965,6 +965,10 @@ def github_pull_request(registry, xml_parent, data):
allows you to selectively test pull requests destined for these
branches only. Supports regular expressions (e.g. 'master',
'feature-.*'). (optional)
+ :arg list black-list-target-branches: Adding branches to this blacklist
+ allows you to selectively prevent pull requests builds destined for
+ these branches. Supports regular expressions (e.g. 'master',
+ 'feature-.*'). (optional)
:arg string auth-id: the auth id to use (optional)
:arg string build-desc-template: the template for build descriptions in
jenkins (optional)
@@ -1058,6 +1062,14 @@ def github_pull_request(registry, xml_parent, data):
'ghprb.GhprbBranch')
XML.SubElement(be, 'branch').text = str(branch)
+ black_list_target_branches = data.get('black-list-target-branches', [])
+ if black_list_target_branches:
+ ghprb_bltb = XML.SubElement(ghprb, 'blackListTargetBranches')
+ for branch in black_list_target_branches:
+ be = XML.SubElement(ghprb_bltb, 'org.jenkinsci.plugins.'
+ 'ghprb.GhprbBranch')
+ XML.SubElement(be, 'branch').text = str(branch)
+
auth_id = data.get('auth-id', '')
if auth_id:
XML.SubElement(ghprb, 'gitHubAuthId').text = str(auth_id)
diff --git a/tests/triggers/fixtures/github-pull-request-full.xml b/tests/triggers/fixtures/github-pull-request-full.xml
index 8448a539..3f282fda 100644
--- a/tests/triggers/fixtures/github-pull-request-full.xml
+++ b/tests/triggers/fixtures/github-pull-request-full.xml
@@ -34,6 +34,14 @@ region</includedRegions>
<branch>testing</branch>
</org.jenkinsci.plugins.ghprb.GhprbBranch>
</whiteListTargetBranches>
+ <blackListTargetBranches>
+ <org.jenkinsci.plugins.ghprb.GhprbBranch>
+ <branch>master</branch>
+ </org.jenkinsci.plugins.ghprb.GhprbBranch>
+ <org.jenkinsci.plugins.ghprb.GhprbBranch>
+ <branch>testing</branch>
+ </org.jenkinsci.plugins.ghprb.GhprbBranch>
+ </blackListTargetBranches>
<gitHubAuthId>123-456-789</gitHubAuthId>
<extensions>
<org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
diff --git a/tests/triggers/fixtures/github-pull-request-full.yaml b/tests/triggers/fixtures/github-pull-request-full.yaml
index af50156f..11a70a36 100644
--- a/tests/triggers/fixtures/github-pull-request-full.yaml
+++ b/tests/triggers/fixtures/github-pull-request-full.yaml
@@ -27,6 +27,9 @@ triggers:
white-list-target-branches:
- master
- testing
+ black-list-target-branches:
+ - master
+ - testing
auth-id: '123-456-789'
status-context: "status context"
triggered-status: "triggered status message"