Add support for the Jenkins Environment Script plugin.
Change-Id: Ia941b3426dd474f0f7d5ddaf9f40a44f7fdbc711
This commit is contained in:
parent
fef529287e
commit
aba095db2f
@ -572,6 +572,27 @@ def env_file(parser, xml_parent, data):
|
||||
eib, 'filePath', data.get('properties-file'))
|
||||
|
||||
|
||||
def env_script(parser, xml_parent, data):
|
||||
"""yaml: env-script
|
||||
Add or override environment variables to the whole build process.
|
||||
Requires the Jenkins `Environment Script Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/Environment+Script+Plugin>`_
|
||||
|
||||
:arg script-content: The script to run (default: '')
|
||||
:arg only-run-on-parent: Only applicable for Matrix Jobs. If true, run only
|
||||
on the matrix parent job (default: false)
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/wrappers/fixtures/env-script001.yaml
|
||||
|
||||
"""
|
||||
el = XML.SubElement(xml_parent, 'com.lookout.jenkins.EnvironmentScript')
|
||||
XML.SubElement(el, 'script').text = data.get('script-content', '')
|
||||
only_on_parent = str(data.get('only-run-on-parent', False)).lower()
|
||||
XML.SubElement(el, 'onlyRunOnParent').text = only_on_parent
|
||||
|
||||
|
||||
def jclouds(parser, xml_parent, data):
|
||||
"""yaml: jclouds
|
||||
Uses JClouds to provide slave launching on most of the currently
|
||||
|
@ -190,6 +190,7 @@ jenkins_jobs.wrappers =
|
||||
copy-to-slave=jenkins_jobs.modules.wrappers:copy_to_slave
|
||||
delivery-pipeline=jenkins_jobs.modules.wrappers:delivery_pipeline
|
||||
env-file=jenkins_jobs.modules.wrappers:env_file
|
||||
env-script=jenkins_jobs.modules.wrappers:env_script
|
||||
exclusion=jenkins_jobs.modules.wrappers:exclusion
|
||||
inject-passwords=jenkins_jobs.modules.wrappers:inject_passwords
|
||||
inject=jenkins_jobs.modules.wrappers:inject
|
||||
|
9
tests/wrappers/fixtures/env-script001.xml
Normal file
9
tests/wrappers/fixtures/env-script001.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<com.lookout.jenkins.EnvironmentScript>
|
||||
<script>echo foo=bar</script>
|
||||
<onlyRunOnParent>true</onlyRunOnParent>
|
||||
</com.lookout.jenkins.EnvironmentScript>
|
||||
</buildWrappers>
|
||||
</project>
|
4
tests/wrappers/fixtures/env-script001.yaml
Normal file
4
tests/wrappers/fixtures/env-script001.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
wrappers:
|
||||
- env-script:
|
||||
script-content: 'echo foo=bar'
|
||||
only-run-on-parent: true
|
Loading…
x
Reference in New Issue
Block a user