Add support for user permissions job filter
Add support for user permissions job filter for views. Change-Id: Ib956fa9387dc86fd8a2d297c443342b5548a9937 Signed-off-by: Anil Belur <askb23@gmail.com>
This commit is contained in:
parent
f4b66dc531
commit
8811c514bd
@ -174,6 +174,19 @@ to the :ref:`view_list` definition.
|
||||
* **match-type** ('str'): Jobs that match a filter
|
||||
to include. (default includeMatched)
|
||||
|
||||
* **user-permissions** (`dict`)
|
||||
:user-permissions:
|
||||
* **match-type** ('str'): Jobs that match a filter to include.
|
||||
(default includeMatched)
|
||||
* **configure** ('bool'): User with configure permissions.
|
||||
(default false)
|
||||
* **amount-type**: ('bool'): User with build permissions.
|
||||
(default false)
|
||||
* **amount**: ('bool'): User with workspace permissions.
|
||||
(default false)
|
||||
* **permission-check**: ('str'): Match user permissions.
|
||||
(default MustMatchAll)
|
||||
|
||||
* **columns** (`list`): List of columns to be shown in view.
|
||||
* **regex** (`str`): . Regular expression for selecting jobs
|
||||
(optional)
|
||||
@ -451,6 +464,23 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
convert_mapping_to_xml(sj_xml, sj_data, mapping,
|
||||
fail_required=True)
|
||||
|
||||
if jobfilter == 'user-permissions':
|
||||
up_xml = XML.SubElement(job_filter_xml,
|
||||
'hudson.views.SecurityFilter')
|
||||
up_xml.set('plugin', 'view-job-filters')
|
||||
up_data = jobfilters.get('user-permissions')
|
||||
mapping = [
|
||||
('match-type', 'includeExcludeTypeString',
|
||||
'includeMatched'),
|
||||
('configure', 'configure', False),
|
||||
('build', 'build', False),
|
||||
('workspace', 'workspace', False),
|
||||
('permission-check', 'permissionCheckType',
|
||||
'MustMatchAll'),
|
||||
]
|
||||
convert_mapping_to_xml(up_xml, up_data, mapping,
|
||||
fail_required=True)
|
||||
|
||||
c_xml = XML.SubElement(root, 'columns')
|
||||
columns = data.get('columns', DEFAULT_COLUMNS)
|
||||
|
||||
|
31
tests/views/fixtures/view_list_security_filter_full.xml
Normal file
31
tests/views/fixtures/view_list_security_filter_full.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<hudson.model.ListView>
|
||||
<name>list-view-name01</name>
|
||||
<description>Sample description</description>
|
||||
<filterExecutors>true</filterExecutors>
|
||||
<filterQueue>true</filterQueue>
|
||||
<properties class="hudson.model.View$PropertyList"/>
|
||||
<jobNames>
|
||||
<comparator class="hudson.util.CaseInsensitiveComparator"/>
|
||||
</jobNames>
|
||||
<jobFilters>
|
||||
<hudson.views.SecurityFilter plugin="view-job-filters">
|
||||
<includeExcludeTypeString>includeMatched</includeExcludeTypeString>
|
||||
<configure>false</configure>
|
||||
<build>false</build>
|
||||
<workspace>false</workspace>
|
||||
<permissionCheckType>MustMatchAll</permissionCheckType>
|
||||
</hudson.views.SecurityFilter>
|
||||
</jobFilters>
|
||||
<columns>
|
||||
<hudson.views.StatusColumn/>
|
||||
<hudson.views.WeatherColumn/>
|
||||
<hudson.views.JobColumn/>
|
||||
<hudson.views.LastSuccessColumn/>
|
||||
<hudson.views.LastFailureColumn/>
|
||||
<hudson.views.LastDurationColumn/>
|
||||
<hudson.views.BuildButtonColumn/>
|
||||
</columns>
|
||||
<recurse>true</recurse>
|
||||
<statusFilter>false</statusFilter>
|
||||
</hudson.model.ListView>
|
14
tests/views/fixtures/view_list_security_filter_full.yaml
Normal file
14
tests/views/fixtures/view_list_security_filter_full.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
user-permissions:
|
||||
match-type: includeMatched
|
||||
configure: false
|
||||
build: false
|
||||
workspace: false
|
||||
permission-check: MustMatchAll
|
||||
recurse: true
|
||||
status-filter: false
|
31
tests/views/fixtures/view_list_security_filter_min.xml
Normal file
31
tests/views/fixtures/view_list_security_filter_min.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<hudson.model.ListView>
|
||||
<name>list-view-name01</name>
|
||||
<description>Sample description</description>
|
||||
<filterExecutors>true</filterExecutors>
|
||||
<filterQueue>true</filterQueue>
|
||||
<properties class="hudson.model.View$PropertyList"/>
|
||||
<jobNames>
|
||||
<comparator class="hudson.util.CaseInsensitiveComparator"/>
|
||||
</jobNames>
|
||||
<jobFilters>
|
||||
<hudson.views.SecurityFilter plugin="view-job-filters">
|
||||
<includeExcludeTypeString>includeMatched</includeExcludeTypeString>
|
||||
<configure>false</configure>
|
||||
<build>false</build>
|
||||
<workspace>false</workspace>
|
||||
<permissionCheckType>MustMatchAll</permissionCheckType>
|
||||
</hudson.views.SecurityFilter>
|
||||
</jobFilters>
|
||||
<columns>
|
||||
<hudson.views.StatusColumn/>
|
||||
<hudson.views.WeatherColumn/>
|
||||
<hudson.views.JobColumn/>
|
||||
<hudson.views.LastSuccessColumn/>
|
||||
<hudson.views.LastFailureColumn/>
|
||||
<hudson.views.LastDurationColumn/>
|
||||
<hudson.views.BuildButtonColumn/>
|
||||
</columns>
|
||||
<recurse>true</recurse>
|
||||
<statusFilter>false</statusFilter>
|
||||
</hudson.model.ListView>
|
10
tests/views/fixtures/view_list_security_filter_min.yaml
Normal file
10
tests/views/fixtures/view_list_security_filter_min.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-filters:
|
||||
user-permissions:
|
||||
permission-check: MustMatchAll
|
||||
recurse: true
|
||||
status-filter: false
|
Loading…
x
Reference in New Issue
Block a user