Add script-type to env-script wrapper

Change-Id: Iac2c6cffd826369d1fd3be70cfc5dd906ee2ca56
Signed-off-by: Michael Jeanson <mjeanson@gmail.com>
This commit is contained in:
Michael Jeanson 2015-11-20 13:20:39 -05:00
parent b6b85a3c8a
commit b17790cc58
4 changed files with 34 additions and 0 deletions

View File

@ -806,6 +806,12 @@ def env_script(parser, xml_parent, data):
<Environment+Script+Plugin>`.
:arg script-content: The script to run (default: '')
:arg str script-type: The script type.
:script-types supported:
* **unix-script** (default)
* **power-shell**
* **batch-script**
:arg only-run-on-parent: Only applicable for Matrix Jobs. If true, run only
on the matrix parent job (default: false)
@ -816,6 +822,18 @@ def env_script(parser, xml_parent, data):
"""
el = XML.SubElement(xml_parent, 'com.lookout.jenkins.EnvironmentScript')
XML.SubElement(el, 'script').text = data.get('script-content', '')
valid_script_types = {
'unix-script': 'unixScript',
'power-shell': 'powerShell',
'batch-script': 'batchScript',
}
script_type = data.get('script-type', 'unix-script')
if script_type not in valid_script_types:
raise InvalidAttributeError('script-type', script_type,
valid_script_types)
XML.SubElement(el, 'scriptType').text = valid_script_types[script_type]
only_on_parent = str(data.get('only-run-on-parent', False)).lower()
XML.SubElement(el, 'onlyRunOnParent').text = only_on_parent

View File

@ -3,6 +3,7 @@
<buildWrappers>
<com.lookout.jenkins.EnvironmentScript>
<script>echo foo=bar</script>
<scriptType>unixScript</scriptType>
<onlyRunOnParent>true</onlyRunOnParent>
</com.lookout.jenkins.EnvironmentScript>
</buildWrappers>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<com.lookout.jenkins.EnvironmentScript>
<script>echo foo=bar</script>
<scriptType>batchScript</scriptType>
<onlyRunOnParent>true</onlyRunOnParent>
</com.lookout.jenkins.EnvironmentScript>
</buildWrappers>
</project>

View File

@ -0,0 +1,5 @@
wrappers:
- env-script:
script-content: 'echo foo=bar'
only-run-on-parent: true
script-type: 'batch-script'