Enable options and use convert_mapping_to_xml for groovy plugin

- Add support for file and command options for groovy plugin
- Update docs
- Update minimal and full tests
- Use convert_mapping_to_xml

Change-Id: I60f600898f9b2852bc420aa3b5c43f63776a6247
Signed-off-by: Anil Belur <askb23@gmail.com>
This commit is contained in:
Anil Belur 2017-02-20 22:02:41 +10:00 committed by Anil Belur
parent 4960f92ad3
commit fce15e414b
No known key found for this signature in database
GPG Key ID: 0FAA11C1B55BFA62
6 changed files with 27 additions and 22 deletions

View File

@ -1111,38 +1111,43 @@ def groovy(registry, xml_parent, data):
:arg str command: Groovy command to run. (Alternative: you can chose a
script file instead)
:arg str version: Groovy version to use. (default '(Default)')
:arg str parameters: Parameters for the Groovy executable. (optional)
:arg str parameters: Parameters for the Groovy executable. (default '')
:arg str script-parameters: These parameters will be passed to the script.
(optional)
(default '')
:arg str properties: Instead of passing properties using the -D parameter
you can define them here. (optional)
you can define them here. (default '')
:arg str java-opts: Direct access to JAVA_OPTS. Properties allows only
-D properties, while sometimes also other properties like -XX need to
be setup. It can be done here. This line is appended at the end of
JAVA_OPTS string. (optional)
JAVA_OPTS string. (default '')
:arg str class-path: Specify script classpath here. Each line is one
class path item. (optional)
class path item. (default '')
Examples:
Minimal Example:
.. literalinclude:: ../../tests/builders/fixtures/groovy001.yaml
.. literalinclude:: ../../tests/builders/fixtures/groovy-minimal.yaml
:language: yaml
.. literalinclude:: ../../tests/builders/fixtures/groovy002.yaml
Full Example:
.. literalinclude:: ../../tests/builders/fixtures/groovy-full.yaml
:language: yaml
"""
root_tag = 'hudson.plugins.groovy.Groovy'
groovy = XML.SubElement(xml_parent, root_tag)
groovy.append(_groovy_common_scriptSource(data))
XML.SubElement(groovy, 'groovyName').text = str(
data.get('version', "(Default)"))
XML.SubElement(groovy, 'parameters').text = str(data.get('parameters', ""))
XML.SubElement(groovy, 'scriptParameters').text = str(
data.get('script-parameters', ""))
XML.SubElement(groovy, 'properties').text = str(data.get('properties', ""))
XML.SubElement(groovy, 'javaOpts').text = str(data.get('java-opts', ""))
XML.SubElement(groovy, 'classPath').text = str(data.get('class-path', ""))
mappings = [
('version', 'groovyName', '(Default)'),
('parameters', 'parameters', ''),
('script-parameters', 'scriptParameters', ''),
('properties', 'properties', ''),
('java-opts', 'javaOpts', ''),
('class-path', 'classPath', '')
]
convert_mapping_to_xml(groovy, data, mappings, fail_required=True)
def system_groovy(registry, xml_parent, data):

View File

@ -2,8 +2,8 @@
<project>
<builders>
<hudson.plugins.groovy.Groovy>
<scriptSource class="hudson.plugins.groovy.FileScriptSource">
<scriptFile>test.groovy</scriptFile>
<scriptSource class="hudson.plugins.groovy.StringScriptSource">
<command>println Hello</command>
</scriptSource>
<groovyName>(Default)</groovyName>
<parameters/>

View File

@ -0,0 +1,3 @@
builders:
- groovy:
command: "println Hello"

View File

@ -1,3 +0,0 @@
builders:
- groovy:
file: "test.groovy"