Update WhiteSource plugin
- Update to use convert_mapping_to_xml - Add minimal test - Add plugin="whitesource" attribute - Add support for requester-email option Change-Id: I7a64b383cae5ba155160386ecd3b9a41ab5ef261 Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
parent
d6add35e72
commit
6a33cb44db
@ -5864,28 +5864,36 @@ def whitesource(parser, xml_parent, data):
|
||||
:arg list excludes: list of libraries to exclude (default '[]')
|
||||
:arg str policies: Whether to override the global settings. Valid values:
|
||||
global, enable, disable (default 'global')
|
||||
:arg str requester-email: Email of the WhiteSource user that requests to
|
||||
update WhiteSource (>=1.5.1) (default '')
|
||||
|
||||
Example:
|
||||
Full Example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/whitesource001.yaml
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/whitesource-full.yaml
|
||||
:language: yaml
|
||||
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/publishers/fixtures/whitesource-minimal.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
|
||||
policies = ['global', 'enable', 'disable']
|
||||
policies_value = str(data.get('policies', 'global').lower())
|
||||
if policies_value not in policies:
|
||||
raise InvalidAttributeError('policies', policies_value, policies)
|
||||
whitesource = XML.SubElement(xml_parent, 'org.whitesource.jenkins.'
|
||||
'WhiteSourcePublisher')
|
||||
XML.SubElement(whitesource, 'jobCheckPolicies').text = policies_value
|
||||
XML.SubElement(whitesource, 'jobApiToken').text = data.get(
|
||||
'override-token', '')
|
||||
XML.SubElement(whitesource, 'product').text = data.get(
|
||||
'product-token', '')
|
||||
XML.SubElement(whitesource, 'productVersion').text = data.get(
|
||||
'version', '')
|
||||
XML.SubElement(whitesource, 'projectToken').text = data.get(
|
||||
'project-token', '')
|
||||
whitesource.set('plugin', 'whitesource')
|
||||
policies = ['global', 'enable', 'disable']
|
||||
|
||||
mappings = [
|
||||
('policies', 'jobCheckPolicies', 'global', policies),
|
||||
('override-token', 'jobApiToken', ''),
|
||||
('product-token', 'product', ''),
|
||||
('version', 'productVersion', ''),
|
||||
('project-token', 'projectToken', ''),
|
||||
('requester-email', 'requesterEmail', ''),
|
||||
]
|
||||
helpers.convert_mapping_to_xml(
|
||||
whitesource, data, mappings, fail_required=True)
|
||||
|
||||
XML.SubElement(whitesource, 'libIncludes').text = ' '.join(
|
||||
data.get('includes', []))
|
||||
XML.SubElement(whitesource, 'libExcludes').text = ' '.join(
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.whitesource.jenkins.WhiteSourcePublisher>
|
||||
<org.whitesource.jenkins.WhiteSourcePublisher plugin="whitesource">
|
||||
<jobCheckPolicies>enable</jobCheckPolicies>
|
||||
<jobApiToken>1231424523412</jobApiToken>
|
||||
<product>abcdefghijklmnopqrstuvwxyzabcdef</product>
|
||||
<productVersion>1.0.17</productVersion>
|
||||
<projectToken>sd;fkljsdfkljasdfkj</projectToken>
|
||||
<requesterEmail>foo@email.com</requesterEmail>
|
||||
<libIncludes>lib/*.jar test/lib/*.jar</libIncludes>
|
||||
<libExcludes>lib/ant*.jar test/lib/ant*.jar</libExcludes>
|
||||
<ignorePomModules>false</ignorePomModules>
|
@ -5,6 +5,7 @@ publishers:
|
||||
policies: enable
|
||||
override-token: "1231424523412"
|
||||
project-token: sd;fkljsdfkljasdfkj
|
||||
requester-email: foo@email.com
|
||||
includes:
|
||||
- lib/*.jar
|
||||
- test/lib/*.jar
|
16
tests/publishers/fixtures/whitesource-minimal.xml
Normal file
16
tests/publishers/fixtures/whitesource-minimal.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.whitesource.jenkins.WhiteSourcePublisher plugin="whitesource">
|
||||
<jobCheckPolicies>global</jobCheckPolicies>
|
||||
<jobApiToken/>
|
||||
<product/>
|
||||
<productVersion/>
|
||||
<projectToken/>
|
||||
<requesterEmail/>
|
||||
<libIncludes/>
|
||||
<libExcludes/>
|
||||
<ignorePomModules>false</ignorePomModules>
|
||||
</org.whitesource.jenkins.WhiteSourcePublisher>
|
||||
</publishers>
|
||||
</project>
|
2
tests/publishers/fixtures/whitesource-minimal.yaml
Normal file
2
tests/publishers/fixtures/whitesource-minimal.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
publishers:
|
||||
- whitesource
|
Loading…
Reference in New Issue
Block a user