Add support for build duration Job Filter plugin
Add support for build duration job filter plugin for views. Change-Id: Ib19775e02f3f7359e69c82b986bc4f89aa51e9df Signed-off-by: Anil Belur <askb23@gmail.com> Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
This commit is contained in:
parent
bc80e5e2f3
commit
726e50aa22
@ -27,11 +27,29 @@ to the :ref:`view_list` definition.
|
||||
* **filter-queue** (`bool`): Show only included jobs in builder
|
||||
queue. (default false)
|
||||
* **job-name** (`list`): List of jobs to be included.
|
||||
* **job-filters** (`dict`): Job filters to be included.
|
||||
* **job-filters** (`dict`): Job filters to be included. Requires
|
||||
:jenkins-wiki:`View Job Filters <View+Job+Filters>`
|
||||
|
||||
* **most-recent** (`dict`)
|
||||
:most-recent: * **max-to-include** (`int`): Maximum number of jobs
|
||||
to include. (default 0)
|
||||
* **check-start-time** (`bool`): Check job start time
|
||||
(default false)
|
||||
* **check-start-time** (`bool`): Check job start
|
||||
time. (default false)
|
||||
|
||||
* **build-duration** (`dict`)
|
||||
:build-duration: * **match-type** ('str'): Jobs that match a filter
|
||||
to include. (default includeMatched)
|
||||
* **build-duration-type** ('str'): Duration of the
|
||||
build. (default Latest)
|
||||
* **amount-type**: ('str'): Duration in hours,
|
||||
days or builds. (default Hours)
|
||||
* **amount**: ('int'): How far back to check.
|
||||
(default 0)
|
||||
* **less-than**: ('bool'): Check build duration
|
||||
less than or more than. (default True)
|
||||
* **build-duration-minutes**: ('int'): Build
|
||||
duration minutes. (default 0)
|
||||
|
||||
* **columns** (`list`): List of columns to be shown in view.
|
||||
* **regex** (`str`): . Regular expression for selecting jobs
|
||||
(optional)
|
||||
@ -106,19 +124,35 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
job_filter_xml = XML.SubElement(root, 'jobFilters')
|
||||
jobfilters = data.get('job-filters', [])
|
||||
|
||||
mapping = [
|
||||
('max-to-include', 'maxToInclude', '0'),
|
||||
('check-start-time', 'checkStartTime', False),
|
||||
]
|
||||
|
||||
for jobfilter in jobfilters:
|
||||
if 'most-recent' in jobfilter:
|
||||
if jobfilter == 'most-recent':
|
||||
mr_xml = XML.SubElement(job_filter_xml,
|
||||
'hudson.views.MostRecentJobsFilter')
|
||||
'hudson.views.MostRecentJobsFilter')
|
||||
mr_xml.set('plugin', 'view-job-filters')
|
||||
mr_data = jobfilter.get('most-recent')
|
||||
mr_data = jobfilters.get('most-recent')
|
||||
mapping = [
|
||||
('max-to-include', 'maxToInclude', '0'),
|
||||
('check-start-time', 'checkStartTime', False),
|
||||
]
|
||||
convert_mapping_to_xml(mr_xml, mr_data, mapping,
|
||||
fail_required=True)
|
||||
fail_required=True)
|
||||
|
||||
if jobfilter == 'build-duration':
|
||||
bd_xml = XML.SubElement(job_filter_xml,
|
||||
'hudson.views.BuildDurationFilter')
|
||||
bd_xml.set('plugin', 'view-job-filters')
|
||||
bd_data = jobfilters.get('build-duration')
|
||||
mapping = [
|
||||
('match-type', 'includeExcludeTypeString',
|
||||
'includeMatched'),
|
||||
('build-duration-type', 'buildCountTypeString', 'Latest'),
|
||||
('amount-type', 'amountTypeString', 'Hours'),
|
||||
('amount', 'amount', '0'),
|
||||
('less-than', 'lessThan', True),
|
||||
('build-duration-minutes', 'buildDurationMinutes', '0'),
|
||||
]
|
||||
convert_mapping_to_xml(bd_xml, bd_data, mapping,
|
||||
fail_required=True)
|
||||
|
||||
c_xml = XML.SubElement(root, 'columns')
|
||||
columns = data.get('columns', DEFAULT_COLUMNS)
|
||||
|
32
tests/views/fixtures/view_list_build_duration_full.xml
Normal file
32
tests/views/fixtures/view_list_build_duration_full.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?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.BuildDurationFilter plugin="view-job-filters">
|
||||
<includeExcludeTypeString>includeMatched</includeExcludeTypeString>
|
||||
<buildCountTypeString>Latest</buildCountTypeString>
|
||||
<amountTypeString>Hours</amountTypeString>
|
||||
<amount>5.0</amount>
|
||||
<lessThan>true</lessThan>
|
||||
<buildDurationMinutes>50.0</buildDurationMinutes>
|
||||
</hudson.views.BuildDurationFilter>
|
||||
</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>
|
15
tests/views/fixtures/view_list_build_duration_full.yaml
Normal file
15
tests/views/fixtures/view_list_build_duration_full.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
build-duration:
|
||||
match-type: includeMatched
|
||||
build-duration-type: Latest
|
||||
amount-type: Hours
|
||||
amount: 5.0
|
||||
less-then: true
|
||||
build-duration-minutes: 50.0
|
||||
recurse: true
|
||||
status-filter: false
|
32
tests/views/fixtures/view_list_build_duration_min.xml
Normal file
32
tests/views/fixtures/view_list_build_duration_min.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?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.BuildDurationFilter plugin="view-job-filters">
|
||||
<includeExcludeTypeString>includeMatched</includeExcludeTypeString>
|
||||
<buildCountTypeString>Latest</buildCountTypeString>
|
||||
<amountTypeString>Hours</amountTypeString>
|
||||
<amount>0</amount>
|
||||
<lessThan>true</lessThan>
|
||||
<buildDurationMinutes>0</buildDurationMinutes>
|
||||
</hudson.views.BuildDurationFilter>
|
||||
</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>
|
10
tests/views/fixtures/view_list_build_duration_min.yaml
Normal file
10
tests/views/fixtures/view_list_build_duration_min.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
build-duration:
|
||||
build-duration-type: Latest
|
||||
recurse: true
|
||||
status-filter: false
|
@ -4,8 +4,8 @@ description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
- most-recent:
|
||||
max-to-include: 25
|
||||
check-start-time: true
|
||||
most-recent:
|
||||
max-to-include: 25
|
||||
check-start-time: true
|
||||
recurse: true
|
||||
status-filter: false
|
||||
|
Loading…
Reference in New Issue
Block a user