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 :arg str command: Groovy command to run. (Alternative: you can chose a
script file instead) script file instead)
:arg str version: Groovy version to use. (default '(Default)') :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. :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 :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 :arg str java-opts: Direct access to JAVA_OPTS. Properties allows only
-D properties, while sometimes also other properties like -XX need to -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 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 :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 :language: yaml
.. literalinclude:: ../../tests/builders/fixtures/groovy002.yaml
Full Example:
.. literalinclude:: ../../tests/builders/fixtures/groovy-full.yaml
:language: yaml :language: yaml
""" """
root_tag = 'hudson.plugins.groovy.Groovy' root_tag = 'hudson.plugins.groovy.Groovy'
groovy = XML.SubElement(xml_parent, root_tag) groovy = XML.SubElement(xml_parent, root_tag)
groovy.append(_groovy_common_scriptSource(data)) groovy.append(_groovy_common_scriptSource(data))
XML.SubElement(groovy, 'groovyName').text = str(
data.get('version', "(Default)")) mappings = [
XML.SubElement(groovy, 'parameters').text = str(data.get('parameters', "")) ('version', 'groovyName', '(Default)'),
XML.SubElement(groovy, 'scriptParameters').text = str( ('parameters', 'parameters', ''),
data.get('script-parameters', "")) ('script-parameters', 'scriptParameters', ''),
XML.SubElement(groovy, 'properties').text = str(data.get('properties', "")) ('properties', 'properties', ''),
XML.SubElement(groovy, 'javaOpts').text = str(data.get('java-opts', "")) ('java-opts', 'javaOpts', ''),
XML.SubElement(groovy, 'classPath').text = str(data.get('class-path', "")) ('class-path', 'classPath', '')
]
convert_mapping_to_xml(groovy, data, mappings, fail_required=True)
def system_groovy(registry, xml_parent, data): def system_groovy(registry, xml_parent, data):

View File

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

View File

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

View File

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