diff --git a/jenkins_jobs/modules/view_list.py b/jenkins_jobs/modules/view_list.py index 93aedd30c..f9b2e8477 100644 --- a/jenkins_jobs/modules/view_list.py +++ b/jenkins_jobs/modules/view_list.py @@ -86,6 +86,17 @@ to the :ref:`view_list` definition. for all jobs in a view, if no jobs have been included by previous filters. (default REMOVE_ALL_IF_ALL_INCLUDED) + * **build-status** (`dict`) + :build-status: + * **match-type** ('str'): Jobs that match a filter + to include. (default includeMatched) + * **never-built** ('bool'): Jobs that are never + built. (default False) + * **building** ('bool'): Jobs that are being + built. (default False) + * **in-build-queue** ('bool'): Jobs that are in + the build queue. (default False) + * **columns** (`list`): List of columns to be shown in view. * **regex** (`str`): . Regular expression for selecting jobs (optional) @@ -238,6 +249,21 @@ class List(jenkins_jobs.modules.base.Base): convert_mapping_to_xml(fb_xml, fb_data, mapping, fail_required=True) + if jobfilter == 'build-status': + bs_xml = XML.SubElement(job_filter_xml, + 'hudson.views.BuildStatusFilter') + bs_xml.set('plugin', 'view-job-filters') + bs_data = jobfilters.get('build-status') + mapping = [ + ('match-type', 'includeExcludeTypeString', + 'includeMatched'), + ('never-built', 'neverBuilt', False), + ('building', 'building', False), + ('in-build-queue', 'inBuildQueue', False), + ] + convert_mapping_to_xml(bs_xml, bs_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_build_status_full.xml b/tests/views/fixtures/view_list_build_status_full.xml new file mode 100644 index 000000000..d11fbcdb9 --- /dev/null +++ b/tests/views/fixtures/view_list_build_status_full.xml @@ -0,0 +1,30 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + true + true + true + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_build_status_full.yaml b/tests/views/fixtures/view_list_build_status_full.yaml new file mode 100644 index 000000000..4d9f6fb32 --- /dev/null +++ b/tests/views/fixtures/view_list_build_status_full.yaml @@ -0,0 +1,13 @@ +name: list-view-name01 +view-type: list +description: 'Sample description' +filter-executors: true +filter-queue: true +job-filters: + build-status: + match-type: includeMatched + never-built: true + building: true + in-build-queue: true +recurse: true +status-filter: false diff --git a/tests/views/fixtures/view_list_build_status_min.xml b/tests/views/fixtures/view_list_build_status_min.xml new file mode 100644 index 000000000..27a021d7e --- /dev/null +++ b/tests/views/fixtures/view_list_build_status_min.xml @@ -0,0 +1,30 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + false + false + false + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_build_status_min.yaml b/tests/views/fixtures/view_list_build_status_min.yaml new file mode 100644 index 000000000..0fea5b5a4 --- /dev/null +++ b/tests/views/fixtures/view_list_build_status_min.yaml @@ -0,0 +1,10 @@ +name: list-view-name01 +view-type: list +description: 'Sample description' +filter-executors: true +filter-queue: true +job-filters: + build-status: + match-type: includeMatched +recurse: true +status-filter: false