Merge "Improve support for EnvInject plugin"

This commit is contained in:
Zuul 2018-06-17 14:27:53 +00:00 committed by Gerrit Code Review
commit d9c6655389
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