Add support for regex job filters
Add support for regex job filters for views. Change-Id: Ic442aaf7f374800f1cd4d0d8a1229ee1e0557891 Signed-off-by: Anil Belur <askb23@gmail.com>
This commit is contained in:
parent
f3e036d65e
commit
0361d56fdf
@ -124,6 +124,14 @@ to the :ref:`view_list` definition.
|
||||
* **match-scm-changes** ('bool'): Jobs matching
|
||||
scm changes. (default False)
|
||||
|
||||
* **regex-job** (`dict`)
|
||||
:regex-job:
|
||||
* **match-type** ('str'): Jobs that match a filter
|
||||
to include. (default includeMatched)
|
||||
* **regex-name** ('str'): Regular expression name.
|
||||
(default '')
|
||||
* **regex** ('str'): Regular expression. (default '')
|
||||
|
||||
* **columns** (`list`): List of columns to be shown in view.
|
||||
* **regex** (`str`): . Regular expression for selecting jobs
|
||||
(optional)
|
||||
@ -315,6 +323,20 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
convert_mapping_to_xml(ur_xml, ur_data, mapping,
|
||||
fail_required=True)
|
||||
|
||||
if jobfilter == 'regex-job':
|
||||
rj_xml = XML.SubElement(job_filter_xml,
|
||||
'hudson.views.RegExJobFilter')
|
||||
rj_xml.set('plugin', 'view-job-filters')
|
||||
rj_data = jobfilters.get('regex-job')
|
||||
mapping = [
|
||||
('match-type', 'includeExcludeTypeString',
|
||||
'includeMatched'),
|
||||
('regex-name', 'valueTypeString', ''),
|
||||
('regex', 'regex', ''),
|
||||
]
|
||||
convert_mapping_to_xml(rj_xml, rj_data, mapping,
|
||||
fail_required=True)
|
||||
|
||||
c_xml = XML.SubElement(root, 'columns')
|
||||
columns = data.get('columns', DEFAULT_COLUMNS)
|
||||
|
||||
|
29
tests/views/fixtures/view_list_regexjobs_filter_full.xml
Normal file
29
tests/views/fixtures/view_list_regexjobs_filter_full.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<hudson.model.ListView>
|
||||
<name>list-view-name01</name>
|
||||
<description>Sample description</description>
|
||||
<filterExecutors>true</filterExecutors>
|
||||
<filterQueue>true</filterQueue>
|
||||
<properties class="hudson.model.View$PropertyList"/>
|
||||
<jobNames>
|
||||
<comparator class="hudson.util.CaseInsensitiveComparator"/>
|
||||
</jobNames>
|
||||
<jobFilters>
|
||||
<hudson.views.RegExJobFilter plugin="view-job-filters">
|
||||
<includeExcludeTypeString>includeMatched</includeExcludeTypeString>
|
||||
<valueTypeString>NAME</valueTypeString>
|
||||
<regex>.*</regex>
|
||||
</hudson.views.RegExJobFilter>
|
||||
</jobFilters>
|
||||
<columns>
|
||||
<hudson.views.StatusColumn/>
|
||||
<hudson.views.WeatherColumn/>
|
||||
<hudson.views.JobColumn/>
|
||||
<hudson.views.LastSuccessColumn/>
|
||||
<hudson.views.LastFailureColumn/>
|
||||
<hudson.views.LastDurationColumn/>
|
||||
<hudson.views.BuildButtonColumn/>
|
||||
</columns>
|
||||
<recurse>true</recurse>
|
||||
<statusFilter>false</statusFilter>
|
||||
</hudson.model.ListView>
|
12
tests/views/fixtures/view_list_regexjobs_filter_full.yaml
Normal file
12
tests/views/fixtures/view_list_regexjobs_filter_full.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
regex-job:
|
||||
match-type: includeMatched
|
||||
regex-name: NAME
|
||||
regex: '.*'
|
||||
recurse: true
|
||||
status-filter: false
|
29
tests/views/fixtures/view_list_regexjobs_filter_min.xml
Normal file
29
tests/views/fixtures/view_list_regexjobs_filter_min.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<hudson.model.ListView>
|
||||
<name>list-view-name01</name>
|
||||
<description>Sample description</description>
|
||||
<filterExecutors>true</filterExecutors>
|
||||
<filterQueue>true</filterQueue>
|
||||
<properties class="hudson.model.View$PropertyList"/>
|
||||
<jobNames>
|
||||
<comparator class="hudson.util.CaseInsensitiveComparator"/>
|
||||
</jobNames>
|
||||
<jobFilters>
|
||||
<hudson.views.RegExJobFilter plugin="view-job-filters">
|
||||
<includeExcludeTypeString>includeMatched</includeExcludeTypeString>
|
||||
<valueTypeString>NAME</valueTypeString>
|
||||
<regex/>
|
||||
</hudson.views.RegExJobFilter>
|
||||
</jobFilters>
|
||||
<columns>
|
||||
<hudson.views.StatusColumn/>
|
||||
<hudson.views.WeatherColumn/>
|
||||
<hudson.views.JobColumn/>
|
||||
<hudson.views.LastSuccessColumn/>
|
||||
<hudson.views.LastFailureColumn/>
|
||||
<hudson.views.LastDurationColumn/>
|
||||
<hudson.views.BuildButtonColumn/>
|
||||
</columns>
|
||||
<recurse>true</recurse>
|
||||
<statusFilter>false</statusFilter>
|
||||
</hudson.model.ListView>
|
11
tests/views/fixtures/view_list_regexjobs_filter_min.yaml
Normal file
11
tests/views/fixtures/view_list_regexjobs_filter_min.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
regex-job:
|
||||
match-type: includeMatched
|
||||
regex-name: NAME
|
||||
recurse: true
|
||||
status-filter: false
|
Loading…
Reference in New Issue
Block a user