Merge "Add support for filtering by name in git source"

This commit is contained in:
Zuul 2018-07-24 14:43:10 +00:00 committed by Gerrit Code Review
commit c1f5048a3c
3 changed files with 12 additions and 0 deletions

View File

@ -489,6 +489,9 @@ def git_scm(xml_parent, data):
(default false)
:arg bool ignore-on-push-notifications: If a job should not trigger upon
push notifications. (default false)
:arg str head-filter-regex: A regular expression for filtering
discovered source branches. Requires the :jenkins-wiki:`SCM API Plugin
<SCM+API+Plugin>`.
:arg list build-strategies: Provides control over whether to build a branch
(or branch like things such as change requests and tags) whenever it is
discovered initially or a change from the previous revision has been
@ -532,6 +535,11 @@ def git_scm(xml_parent, data):
XML.SubElement(
traits, ''.join([traits_path, '.IgnoreOnPushNotificationTrait']))
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('build-strategies', None):
build_strategies(xml_parent, data)

View File

@ -38,6 +38,9 @@
<traits>
<jenkins.plugins.git.traits.TagDiscoveryTrait/>
<jenkins.plugins.git.traits.IgnoreOnPushNotificationTrait/>
<jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
<regex>master|\d+\.\d+</regex>
</jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
</traits>
</source>
<buildStrategies>

View File

@ -8,6 +8,7 @@ scm:
discover-branches: false
ignore-on-push-notifications: true
discover-tags: true
head-filter-regex: 'master|\d+\.\d+'
build-strategies:
- tags:
ignore-tags-newer-than: 1