Add script-type to env-script wrapper
Change-Id: Iac2c6cffd826369d1fd3be70cfc5dd906ee2ca56 Signed-off-by: Michael Jeanson <mjeanson@gmail.com>
This commit is contained in:
parent
b6b85a3c8a
commit
b17790cc58
@ -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
|
||||
|
||||
|
@ -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>
|
||||
|
10
tests/wrappers/fixtures/env-script002.xml
Normal file
10
tests/wrappers/fixtures/env-script002.xml
Normal 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>
|
5
tests/wrappers/fixtures/env-script002.yaml
Normal file
5
tests/wrappers/fixtures/env-script002.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
wrappers:
|
||||
- env-script:
|
||||
script-content: 'echo foo=bar'
|
||||
only-run-on-parent: true
|
||||
script-type: 'batch-script'
|
Loading…
Reference in New Issue
Block a user