diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py
index 1c331b091..eec044116 100644
--- a/jenkins_jobs/modules/project_multibranch.py
+++ b/jenkins_jobs/modules/project_multibranch.py
@@ -968,6 +968,11 @@ def github_scm(xml_parent, data):
helpers.convert_mapping_to_xml(
dpro, data, dpro_mapping, fail_required=True)
+ if data.get('head-filter-regex', None):
+ rshf = XML.SubElement(traits,
+ 'jenkins.scm.impl.trait.RegexSCMHeadFilterTrait')
+ XML.SubElement(rshf, 'regex').text = data.get('head-filter-regex')
+
if data.get('property-strategies', None):
property_strategies(xml_parent, data)
diff --git a/tests/multibranch/fixtures/scm_github_full.xml b/tests/multibranch/fixtures/scm_github_full.xml
index a74e2e6d4..cc4efcc10 100644
--- a/tests/multibranch/fixtures/scm_github_full.xml
+++ b/tests/multibranch/fixtures/scm_github_full.xml
@@ -52,6 +52,9 @@
3
+
+ (.*/master|.*/release/.*)
+
diff --git a/tests/multibranch/fixtures/scm_github_full.yaml b/tests/multibranch/fixtures/scm_github_full.yaml
index 9b74e8377..a45ecb65e 100644
--- a/tests/multibranch/fixtures/scm_github_full.yaml
+++ b/tests/multibranch/fixtures/scm_github_full.yaml
@@ -10,6 +10,7 @@ scm:
repo-owner: example-owner
credentials-id: example-credential
branch-discovery: all
+ head-filter-regex: "(.*/master|.*/release/.*)"
discover-pr-forks-strategy: both
discover-pr-forks-trust: everyone
discover-pr-origin: both