Adds github scm multibranch regex branch filter
This commit adds the ability to filter discovered branches in a multibranch project using a regex filter. This is done by adding a 'head-filter-regex' key in the github scm configuration inside the multibranch job yaml - it maps to a <jenkins.scm.impl.trait.RegexSCMHeadFilterTrait> element containing a <regex> element in the resulting job. Change-Id: I8c88a8b131cdc51d2c8abb13397637ebbf6d1373 Signed-off-by: amit lin <amitl@totango.com>
This commit is contained in:
parent
b1499530db
commit
ff338dc948
|
@ -968,6 +968,11 @@ def github_scm(xml_parent, data):
|
||||||
helpers.convert_mapping_to_xml(
|
helpers.convert_mapping_to_xml(
|
||||||
dpro, data, dpro_mapping, fail_required=True)
|
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):
|
if data.get('property-strategies', None):
|
||||||
property_strategies(xml_parent, data)
|
property_strategies(xml_parent, data)
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
<org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
|
<org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
|
||||||
<strategyId>3</strategyId>
|
<strategyId>3</strategyId>
|
||||||
</org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
|
</org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
|
||||||
|
<jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
|
||||||
|
<regex>(.*/master|.*/release/.*)</regex>
|
||||||
|
</jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
|
||||||
<jenkins.plugins.git.traits.CleanAfterCheckoutTrait>
|
<jenkins.plugins.git.traits.CleanAfterCheckoutTrait>
|
||||||
<extension class="hudson.plugins.git.extensions.impl.CleanCheckout"/>
|
<extension class="hudson.plugins.git.extensions.impl.CleanCheckout"/>
|
||||||
</jenkins.plugins.git.traits.CleanAfterCheckoutTrait>
|
</jenkins.plugins.git.traits.CleanAfterCheckoutTrait>
|
||||||
|
|
|
@ -10,6 +10,7 @@ scm:
|
||||||
repo-owner: example-owner
|
repo-owner: example-owner
|
||||||
credentials-id: example-credential
|
credentials-id: example-credential
|
||||||
branch-discovery: all
|
branch-discovery: all
|
||||||
|
head-filter-regex: "(.*/master|.*/release/.*)"
|
||||||
discover-pr-forks-strategy: both
|
discover-pr-forks-strategy: both
|
||||||
discover-pr-forks-trust: everyone
|
discover-pr-forks-trust: everyone
|
||||||
discover-pr-origin: both
|
discover-pr-origin: both
|
||||||
|
|
Loading…
Reference in New Issue