diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py
index a888b8f41..004236f80 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 8448a5398..3f282fda3 100644
--- a/tests/triggers/fixtures/github-pull-request-full.xml
+++ b/tests/triggers/fixtures/github-pull-request-full.xml
@@ -34,6 +34,14 @@ region
testing
+
+
+ master
+
+
+ testing
+
+
123-456-789
diff --git a/tests/triggers/fixtures/github-pull-request-full.yaml b/tests/triggers/fixtures/github-pull-request-full.yaml
index af50156fa..11a70a36d 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"