diff --git a/jenkins_jobs/modules/view_list.py b/jenkins_jobs/modules/view_list.py index ea97b7624..2655cedd5 100644 --- a/jenkins_jobs/modules/view_list.py +++ b/jenkins_jobs/modules/view_list.py @@ -132,6 +132,13 @@ to the :ref:`view_list` definition. (default '') * **regex** ('str'): Regular expression. (default '') + * **job-tpye** (`dict`) + :job-type: + * **match-type** ('str'): Jobs that match a filter to include. + (default includeMatched) + * **job-type** ('str'): Type of Job. + (default hudson.model.FreeStyleProject) + * **columns** (`list`): List of columns to be shown in view. * **regex** (`str`): . Regular expression for selecting jobs (optional) @@ -337,6 +344,19 @@ class List(jenkins_jobs.modules.base.Base): convert_mapping_to_xml(rj_xml, rj_data, mapping, fail_required=True) + if jobfilter == 'job-type': + jt_xml = XML.SubElement(job_filter_xml, + 'hudson.views.JobTypeFilter') + jt_xml.set('plugin', 'view-job-filters') + jt_data = jobfilters.get('job-type') + mapping = [ + ('match-type', 'includeExcludeTypeString', + 'includeMatched'), + ('job-type', 'jobType', 'hudson.model.FreeStyleProject'), + ] + convert_mapping_to_xml(jt_xml, jt_data, mapping, + fail_required=True) + c_xml = XML.SubElement(root, 'columns') columns = data.get('columns', DEFAULT_COLUMNS) diff --git a/tests/views/fixtures/view_list_jobtype_filter_full.xml b/tests/views/fixtures/view_list_jobtype_filter_full.xml new file mode 100644 index 000000000..2de03deaf --- /dev/null +++ b/tests/views/fixtures/view_list_jobtype_filter_full.xml @@ -0,0 +1,28 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + hudson.model.FreeStyleProject + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_jobtype_filter_full.yaml b/tests/views/fixtures/view_list_jobtype_filter_full.yaml new file mode 100644 index 000000000..20689de0c --- /dev/null +++ b/tests/views/fixtures/view_list_jobtype_filter_full.yaml @@ -0,0 +1,11 @@ +name: list-view-name01 +view-type: list +description: 'Sample description' +filter-executors: true +filter-queue: true +job-filters: + job-type: + match-type: includeMatched + job-tpye: hudson.model.FreeStyleProject +recurse: true +status-filter: false diff --git a/tests/views/fixtures/view_list_jobtype_filter_min.xml b/tests/views/fixtures/view_list_jobtype_filter_min.xml new file mode 100644 index 000000000..2de03deaf --- /dev/null +++ b/tests/views/fixtures/view_list_jobtype_filter_min.xml @@ -0,0 +1,28 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + hudson.model.FreeStyleProject + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_jobtype_filter_min.yaml b/tests/views/fixtures/view_list_jobtype_filter_min.yaml new file mode 100644 index 000000000..f5138a18f --- /dev/null +++ b/tests/views/fixtures/view_list_jobtype_filter_min.yaml @@ -0,0 +1,10 @@ +name: list-view-name01 +view-type: list +description: 'Sample description' +filter-executors: true +filter-queue: true +job-filters: + job-type: + match-type: includeMatched +recurse: true +status-filter: false