Improve support for EnvInject plugin

Adds support for groovy script option and sandbox option.
Updated new example YAML and XML files.

Story: #2000922
Task: #3553

Change-Id: Iad44f9a0a776060c6fb1acfc3ebb44fa3c5acef2
This commit is contained in:
tanhengyeow 2018-05-27 13:59:23 +08:00
parent 307c09cff3
commit 1f857fc816
5 changed files with 58 additions and 7 deletions

View File

@ -920,15 +920,17 @@ def inject(registry, xml_parent, data):
:arg str script-file: path to the script file (optional)
:arg str script-content: contents of a script (optional)
:arg bool load-from-master: load files from master (default false)
:arg str groovy-script: contents of the groovy script (optional)
:arg bool groovy-sandbox: use groovy sandbox (default false)
Example::
Minimal Example:
.. literalinclude:: /../../tests/wrappers/fixtures/inject-minimal.yaml
Full Example:
.. literalinclude:: /../../tests/wrappers/fixtures/inject-full.yaml
wrappers:
- inject:
properties-file: /usr/local/foo
properties-content: PATH=/foo/bar
script-file: /usr/local/foo.sh
script-content: echo $PATH
"""
eib = XML.SubElement(xml_parent, 'EnvInjectBuildWrapper')
info = XML.SubElement(eib, 'info')
@ -941,6 +943,14 @@ def inject(registry, xml_parent, data):
]
convert_mapping_to_xml(info, data, mapping, fail_required=False)
secure_groovy_script = XML.SubElement(info, 'secureGroovyScript')
mapping = [
('groovy-script', 'script', None),
('groovy-sandbox', 'sandbox', False),
]
convert_mapping_to_xml(secure_groovy_script, data, mapping,
fail_required=False)
def inject_ownership_variables(registry, xml_parent, data):
"""yaml: inject-ownership-variables

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<EnvInjectBuildWrapper>
<info>
<propertiesFilePath>example.prop full</propertiesFilePath>
<propertiesContent>EXAMPLE=foo-bar full</propertiesContent>
<scriptFilePath>scriptfull.sh</scriptFilePath>
<scriptContent>test script content full</scriptContent>
<loadFilesFromMaster>false</loadFilesFromMaster>
<secureGroovyScript>
<script>test groovy-script location full</script>
<sandbox>true</sandbox>
</secureGroovyScript>
</info>
</EnvInjectBuildWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,8 @@
wrappers:
- inject:
properties-file: example.prop full
properties-content: EXAMPLE=foo-bar full
script-file: scriptfull.sh
script-content: test script content full
groovy-script: test groovy-script location full
groovy-sandbox: true

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<EnvInjectBuildWrapper>
<info>
<loadFilesFromMaster>false</loadFilesFromMaster>
<secureGroovyScript>
<sandbox>false</sandbox>
</secureGroovyScript>
</info>
</EnvInjectBuildWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,2 @@
wrappers:
- inject