diff --git a/jenkins_jobs/modules/view_list.py b/jenkins_jobs/modules/view_list.py index 8a32eadb9..c02591072 100644 --- a/jenkins_jobs/modules/view_list.py +++ b/jenkins_jobs/modules/view_list.py @@ -50,6 +50,18 @@ to the :ref:`view_list` definition. * **build-duration-minutes**: ('int'): Build duration minutes. (default 0) + * **build-trend** (`dict`) + :build-trend: * **match-type** ('str'): Jobs that match a filter + to include. (default includeMatched) + * **build-trend-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) + * **status**: ('str'): Job status. + (default Completed) + * **columns** (`list`): List of columns to be shown in view. * **regex** (`str`): . Regular expression for selecting jobs (optional) @@ -154,6 +166,22 @@ class List(jenkins_jobs.modules.base.Base): convert_mapping_to_xml(bd_xml, bd_data, mapping, fail_required=True) + if jobfilter == 'build-trend': + bt_xml = XML.SubElement(job_filter_xml, + 'hudson.views.BuildTrendFilter') + bt_xml.set('plugin', 'view-job-filters') + bt_data = jobfilters.get('build-trend') + mapping = [ + ('match-type', 'includeExcludeTypeString', + 'includeMatched'), + ('build-trend-type', 'buildCountTypeString', 'Latest'), + ('amount-type', 'amountTypeString', 'Hours'), + ('amount', 'amount', '0'), + ('status', 'statusTypeString', 'Completed'), + ] + convert_mapping_to_xml(bt_xml, bt_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_trend_full.xml b/tests/views/fixtures/view_list_build_trend_full.xml new file mode 100644 index 000000000..bcc5eda6d --- /dev/null +++ b/tests/views/fixtures/view_list_build_trend_full.xml @@ -0,0 +1,31 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + Latest + Hours + 7.0 + Completed + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_build_trend_full.yaml b/tests/views/fixtures/view_list_build_trend_full.yaml new file mode 100644 index 000000000..dba0dd944 --- /dev/null +++ b/tests/views/fixtures/view_list_build_trend_full.yaml @@ -0,0 +1,14 @@ +name: list-view-name01 +view-type: list +description: 'Sample description' +filter-executors: true +filter-queue: true +job-filters: + build-trend: + match-type: includeMatched + build-count-type: Latest + amount-type: Hours + amount: 7.0 + status: Completed +recurse: true +status-filter: false diff --git a/tests/views/fixtures/view_list_build_trend_min.xml b/tests/views/fixtures/view_list_build_trend_min.xml new file mode 100644 index 000000000..028acd3e2 --- /dev/null +++ b/tests/views/fixtures/view_list_build_trend_min.xml @@ -0,0 +1,31 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + Latest + Hours + 0 + Completed + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_build_trend_min.yaml b/tests/views/fixtures/view_list_build_trend_min.yaml new file mode 100644 index 000000000..a8a62ef58 --- /dev/null +++ b/tests/views/fixtures/view_list_build_trend_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-trend: + match-type: includeMatched +recurse: true +status-filter: false