diff --git a/jenkins_jobs/modules/view_list.py b/jenkins_jobs/modules/view_list.py index ca5563397..c991832c3 100644 --- a/jenkins_jobs/modules/view_list.py +++ b/jenkins_jobs/modules/view_list.py @@ -155,6 +155,13 @@ to the :ref:`view_list` definition. * **max-builds-to-match** ('int'): Maximum builds to match. (default 0) + * **other-views** (`dict`) + :other-views: + * **match-type** ('str'): Jobs that match a filter + to include. (default includeMatched) + * **view-name** ('str'): View name. + (default select a view other than this one) + * **columns** (`list`): List of columns to be shown in view. * **regex** (`str`): . Regular expression for selecting jobs (optional) @@ -393,6 +400,20 @@ class List(jenkins_jobs.modules.base.Base): convert_mapping_to_xml(pr_xml, pr_data, mapping, fail_required=True) + if jobfilter == 'other-views': + ov_xml = XML.SubElement(job_filter_xml, + 'hudson.views.OtherViewsFilter') + ov_xml.set('plugin', 'view-job-filters') + ov_data = jobfilters.get('other-views') + mapping = [ + ('match-type', 'includeExcludeTypeString', + 'includeMatched'), + ('view-name', 'otherViewName', + '<select a view other than this one>'), + ] + convert_mapping_to_xml(ov_xml, ov_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_otherviews_filter_full.xml b/tests/views/fixtures/view_list_otherviews_filter_full.xml new file mode 100644 index 000000000..5db2e9e85 --- /dev/null +++ b/tests/views/fixtures/view_list_otherviews_filter_full.xml @@ -0,0 +1,28 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + &lt;select a view other than this one&gt; + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_otherviews_filter_full.yaml b/tests/views/fixtures/view_list_otherviews_filter_full.yaml new file mode 100644 index 000000000..f7229a344 --- /dev/null +++ b/tests/views/fixtures/view_list_otherviews_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: + other-views: + match-type: includeMatched + view-name: '<select a view other than this one>' +recurse: true +status-filter: false diff --git a/tests/views/fixtures/view_list_otherviews_filter_min.xml b/tests/views/fixtures/view_list_otherviews_filter_min.xml new file mode 100644 index 000000000..5db2e9e85 --- /dev/null +++ b/tests/views/fixtures/view_list_otherviews_filter_min.xml @@ -0,0 +1,28 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + &lt;select a view other than this one&gt; + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_otherviews_filter_min.yaml b/tests/views/fixtures/view_list_otherviews_filter_min.yaml new file mode 100644 index 000000000..8972afc8d --- /dev/null +++ b/tests/views/fixtures/view_list_otherviews_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: + other-views: + match-type: includeMatched +recurse: true +status-filter: false