diff --git a/jenkins_jobs/modules/view_list.py b/jenkins_jobs/modules/view_list.py index f9b2e8477..ca642e85f 100644 --- a/jenkins_jobs/modules/view_list.py +++ b/jenkins_jobs/modules/view_list.py @@ -97,6 +97,33 @@ to the :ref:`view_list` definition. * **in-build-queue** ('bool'): Jobs that are in the build queue. (default False) + * **user-relevence** (`dict`) + :user-relevence: + * **match-type** ('str'): Jobs that match a filter + to include. (default includeMatched) + * **build-count** ('str'): Count of builds. + (default AtLeastOne) + * **amount-type**: ('str'): Duration in hours, + days or builds. (default Hours) + * **amount**: ('int'): How far back to check. + (default 0) + * **match-user-id** ('bool'): Jobs matching + user-id. (default False) + * **match-user-fullname** ('bool'): Jobs + matching user fullname. (default False) + * **ignore-case** ('bool'): Ignore case. + (default False) + * **ignore-whitespace** ('bool'): Ignore + whitespace. (default False) + * **ignore-non-alphaNumeric** ('bool'): Ignore + non-alphaNumeric. (default False) + * **match-builder** ('bool'): Jobs matching + builder. (default False) + * **match-email** ('bool'): Jobs matching + email. (default False) + * **match-scm-changes** ('bool'): Jobs matching + scm changes. (default False) + * **columns** (`list`): List of columns to be shown in view. * **regex** (`str`): . Regular expression for selecting jobs (optional) @@ -264,6 +291,30 @@ class List(jenkins_jobs.modules.base.Base): convert_mapping_to_xml(bs_xml, bs_data, mapping, fail_required=True) + if jobfilter == 'user-relevence': + ur_xml = XML.SubElement(job_filter_xml, + 'hudson.views.UserRelevanceFilter') + ur_xml.set('plugin', 'view-job-filters') + ur_data = jobfilters.get('user-relevence') + mapping = [ + ('match-type', 'includeExcludeTypeString', + 'includeMatched'), + ('build-count', 'buildCountTypeString', 'AtLeastOne'), + ('amount-type', 'amountTypeString', 'Hours'), + ('amount', 'amount', '0'), + ('match-user-id', 'matchUserId', False), + ('match-user-fullname', 'matchUserFullName', False), + ('ignore-case', 'ignoreCase', False), + ('ignore-whitespace', 'ignoreWhitespace', False), + ('ignore-non-alphaNumeric', 'ignoreNonAlphaNumeric', + False), + ('match-builder', 'matchBuilder', False), + ('match-email', 'matchEmail', False), + ('match-scm-changes', 'matchScmChanges', False), + ] + convert_mapping_to_xml(ur_xml, ur_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_userrelevence_filter_full.xml b/tests/views/fixtures/view_list_userrelevence_filter_full.xml new file mode 100644 index 000000000..9e0fce512 --- /dev/null +++ b/tests/views/fixtures/view_list_userrelevence_filter_full.xml @@ -0,0 +1,38 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + AtLeastOne + Hours + 1.0 + true + true + true + true + true + true + true + true + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_userrelevence_filter_full.yaml b/tests/views/fixtures/view_list_userrelevence_filter_full.yaml new file mode 100644 index 000000000..d8bd3e339 --- /dev/null +++ b/tests/views/fixtures/view_list_userrelevence_filter_full.yaml @@ -0,0 +1,21 @@ +name: list-view-name01 +view-type: list +description: 'Sample description' +filter-executors: true +filter-queue: true +job-filters: + user-relevence: + match-type: includeMatched + build-count: AtLeastOne + mount-type: Hours + amount: 1.0 + match-user-id: true + match-user-fullname: true + ignore-case: true + ignore-whitespace: true + ignore-non-alphaNumeric: true + match-builder: true + match-email: true + match-scm-changes: true +recurse: true +status-filter: false diff --git a/tests/views/fixtures/view_list_userrelevence_filter_min.xml b/tests/views/fixtures/view_list_userrelevence_filter_min.xml new file mode 100644 index 000000000..7038d7302 --- /dev/null +++ b/tests/views/fixtures/view_list_userrelevence_filter_min.xml @@ -0,0 +1,38 @@ + + + list-view-name01 + Sample description + true + true + + + + + + + includeMatched + AtLeastOne + Hours + 0 + false + false + false + false + false + false + false + false + + + + + + + + + + + + true + false + diff --git a/tests/views/fixtures/view_list_userrelevence_filter_min.yaml b/tests/views/fixtures/view_list_userrelevence_filter_min.yaml new file mode 100644 index 000000000..bd55205f4 --- /dev/null +++ b/tests/views/fixtures/view_list_userrelevence_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: + user-relevence: + match-type: includeMatched +recurse: true +status-filter: false