summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs/modules/view_list.py
diff options
context:
space:
mode:
authorAnil Belur <askb23@gmail.com>2018-01-25 14:11:46 +1000
committerAnil Belur <askb23@gmail.com>2018-02-10 07:18:00 +0000
commitc7945da64b25a9be3901df66fc86d3f6c3b63d3f (patch)
tree9aabab0cae915ae3783f7325b32b1e6b0934b25f /jenkins_jobs/modules/view_list.py
parent92fcbab1230f2b6e421062714dc7bc6a0ffd3e37 (diff)
downloadpython-jenkins-job-builder-c7945da64b25a9be3901df66fc86d3f6c3b63d3f.tar.gz
python-jenkins-job-builder-c7945da64b25a9be3901df66fc86d3f6c3b63d3f.tar.xz
python-jenkins-job-builder-c7945da64b25a9be3901df66fc86d3f6c3b63d3f.zip
Add support for most recent job filters
Pushing job filters is not supported with JJB 2.0. The change implements the ability to update most recent job filter to views. Change-Id: I23d09dfb26539c2b00f565729f706cbc75212987 Signed-off-by: Anil Belur <askb23@gmail.com>
Diffstat (limited to 'jenkins_jobs/modules/view_list.py')
-rw-r--r--jenkins_jobs/modules/view_list.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/view_list.py b/jenkins_jobs/modules/view_list.py
index 7b85de3a..3d08beca 100644
--- a/jenkins_jobs/modules/view_list.py
+++ b/jenkins_jobs/modules/view_list.py
@@ -27,6 +27,11 @@ 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.
+ :most-recent: * **max-to-include** (`int`): Maximum number of jobs
+ to include. (default 0)
+ * **check-start-time** (`bool`): Check job start time
+ (default false)
* **columns** (`list`): List of columns to be shown in view.
* **regex** (`str`): . Regular expression for selecting jobs
(optional)
@@ -88,7 +93,23 @@ class List(jenkins_jobs.modules.base.Base):
if jobnames is not None:
for jobname in jobnames:
XML.SubElement(jn_xml, 'string').text = str(jobname)
- XML.SubElement(root, 'jobFilters')
+
+ 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:
+ mr_xml = XML.SubElement(job_filter_xml,
+ 'hudson.views.MostRecentJobsFilter')
+ mr_xml.set('plugin', 'view-job-filters')
+ mr_data = jobfilter.get('most-recent')
+ convert_mapping_to_xml(mr_xml, mr_data, mapping,
+ fail_required=True)
c_xml = XML.SubElement(root, 'columns')
columns = data.get('columns', DEFAULT_COLUMNS)