Add support for fallback Job Filters

Add support for fallback Job Filters for views.

Change-Id: I06290c74df62e68fe78f07fc8d77236c206cf5ad
Signed-off-by: Anil Belur <askb23@gmail.com>
This commit is contained in:
Anil Belur 2018-03-02 12:44:51 +10:00
parent 3264b244b5
commit 55da305df0
5 changed files with 96 additions and 0 deletions

View File

@ -80,6 +80,12 @@ to the :ref:`view_list` definition.
* **stable** ('bool'): Jobs with status
stable. (default False)
* **fallback** (`dict`)
:fallback:
* **fallback-type** ('str'): Fallback type to include/exclude
for all jobs in a view, if no jobs have been included by
previous filters. (default REMOVE_ALL_IF_ALL_INCLUDED)
* **columns** (`list`): List of columns to be shown in view.
* **regex** (`str`): . Regular expression for selecting jobs
(optional)
@ -218,6 +224,20 @@ class List(jenkins_jobs.modules.base.Base):
convert_mapping_to_xml(js_xml, js_data, mapping,
fail_required=True)
if jobfilter == 'fallback':
fb_xml = XML.SubElement(job_filter_xml,
'hudson.views.AddRemoveFallbackFilter')
fb_xml.set('plugin', 'view-job-filters')
fb_data = jobfilters.get('fallback')
mapping = [
('fallback-type', 'fallbackTypeString',
'REMOVE_ALL_IF_ALL_INCLUDED'),
('fallback-type', 'fallbackType',
'REMOVE_ALL_IF_ALL_INCLUDED'),
]
convert_mapping_to_xml(fb_xml, fb_data, mapping,
fail_required=True)
c_xml = XML.SubElement(root, 'columns')
columns = data.get('columns', DEFAULT_COLUMNS)

View File

@ -0,0 +1,28 @@
<?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.AddRemoveFallbackFilter plugin="view-job-filters">
<fallbackTypeString>REMOVE_ALL_IF_ALL_INCLUDED</fallbackTypeString>
<fallbackType>REMOVE_ALL_IF_ALL_INCLUDED</fallbackType>
</hudson.views.AddRemoveFallbackFilter>
</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>

View File

@ -0,0 +1,10 @@
name: list-view-name01
view-type: list
description: 'Sample description'
filter-executors: true
filter-queue: true
job-filters:
fallback:
fallback-type: REMOVE_ALL_IF_ALL_INCLUDED
recurse: true
status-filter: false

View File

@ -0,0 +1,28 @@
<?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.AddRemoveFallbackFilter plugin="view-job-filters">
<fallbackTypeString>ADD_ALL_IF_ALL_INCLUDED</fallbackTypeString>
<fallbackType>ADD_ALL_IF_ALL_INCLUDED</fallbackType>
</hudson.views.AddRemoveFallbackFilter>
</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>

View File

@ -0,0 +1,10 @@
name: list-view-name01
view-type: list
description: 'Sample description'
filter-executors: true
filter-queue: true
job-filters:
fallback:
fallback-type: ADD_ALL_IF_ALL_INCLUDED
recurse: true
status-filter: false