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 list excludes: list of libraries to exclude (default '[]')
|
||||||
:arg str policies: Whether to override the global settings. Valid values:
|
:arg str policies: Whether to override the global settings. Valid values:
|
||||||
global, enable, disable (default 'global')
|
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
|
: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.'
|
whitesource = XML.SubElement(xml_parent, 'org.whitesource.jenkins.'
|
||||||
'WhiteSourcePublisher')
|
'WhiteSourcePublisher')
|
||||||
XML.SubElement(whitesource, 'jobCheckPolicies').text = policies_value
|
whitesource.set('plugin', 'whitesource')
|
||||||
XML.SubElement(whitesource, 'jobApiToken').text = data.get(
|
policies = ['global', 'enable', 'disable']
|
||||||
'override-token', '')
|
|
||||||
XML.SubElement(whitesource, 'product').text = data.get(
|
mappings = [
|
||||||
'product-token', '')
|
('policies', 'jobCheckPolicies', 'global', policies),
|
||||||
XML.SubElement(whitesource, 'productVersion').text = data.get(
|
('override-token', 'jobApiToken', ''),
|
||||||
'version', '')
|
('product-token', 'product', ''),
|
||||||
XML.SubElement(whitesource, 'projectToken').text = data.get(
|
('version', 'productVersion', ''),
|
||||||
'project-token', '')
|
('project-token', 'projectToken', ''),
|
||||||
|
('requester-email', 'requesterEmail', ''),
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(
|
||||||
|
whitesource, data, mappings, fail_required=True)
|
||||||
|
|
||||||
XML.SubElement(whitesource, 'libIncludes').text = ' '.join(
|
XML.SubElement(whitesource, 'libIncludes').text = ' '.join(
|
||||||
data.get('includes', []))
|
data.get('includes', []))
|
||||||
XML.SubElement(whitesource, 'libExcludes').text = ' '.join(
|
XML.SubElement(whitesource, 'libExcludes').text = ' '.join(
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<org.whitesource.jenkins.WhiteSourcePublisher>
|
<org.whitesource.jenkins.WhiteSourcePublisher plugin="whitesource">
|
||||||
<jobCheckPolicies>enable</jobCheckPolicies>
|
<jobCheckPolicies>enable</jobCheckPolicies>
|
||||||
<jobApiToken>1231424523412</jobApiToken>
|
<jobApiToken>1231424523412</jobApiToken>
|
||||||
<product>abcdefghijklmnopqrstuvwxyzabcdef</product>
|
<product>abcdefghijklmnopqrstuvwxyzabcdef</product>
|
||||||
<productVersion>1.0.17</productVersion>
|
<productVersion>1.0.17</productVersion>
|
||||||
<projectToken>sd;fkljsdfkljasdfkj</projectToken>
|
<projectToken>sd;fkljsdfkljasdfkj</projectToken>
|
||||||
|
<requesterEmail>foo@email.com</requesterEmail>
|
||||||
<libIncludes>lib/*.jar test/lib/*.jar</libIncludes>
|
<libIncludes>lib/*.jar test/lib/*.jar</libIncludes>
|
||||||
<libExcludes>lib/ant*.jar test/lib/ant*.jar</libExcludes>
|
<libExcludes>lib/ant*.jar test/lib/ant*.jar</libExcludes>
|
||||||
<ignorePomModules>false</ignorePomModules>
|
<ignorePomModules>false</ignorePomModules>
|
@ -5,6 +5,7 @@ publishers:
|
|||||||
policies: enable
|
policies: enable
|
||||||
override-token: "1231424523412"
|
override-token: "1231424523412"
|
||||||
project-token: sd;fkljsdfkljasdfkj
|
project-token: sd;fkljsdfkljasdfkj
|
||||||
|
requester-email: foo@email.com
|
||||||
includes:
|
includes:
|
||||||
- lib/*.jar
|
- lib/*.jar
|
||||||
- test/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