diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 8a8061a65..144ed5945 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -519,6 +519,31 @@ def inject(parser, xml_parent, data): XML.SubElement(info, 'loadFilesFromMaster').text = 'false' +def inject_ownership_variables(parser, xml_parent, data): + """yaml: inject-ownership-variables + Inject ownership variables to the build as environment variables. + Requires the Jenkins `EnvInject Plugin and Jenkins Ownership plugin + + `_ + + :arg bool job-variables: inject job ownership variables to the job + (default false) + :arg bool node-variables: inject node ownership variables to the job + (default false) + + Example: + + .. literalinclude:: /../../tests/wrappers/fixtures/ownership001.yaml + + """ + ownership = XML.SubElement(xml_parent, 'com.synopsys.arc.jenkins.plugins.' + 'ownership.wrappers.OwnershipBuildWrapper') + XML.SubElement(ownership, 'injectNodeOwnership').text = \ + str(data.get('node-variables', False)).lower() + XML.SubElement(ownership, 'injectJobOwnership').text = \ + str(data.get('job-variables', False)).lower() + + def inject_passwords(parser, xml_parent, data): """yaml: inject-passwords Inject passwords to the build as environment variables. diff --git a/setup.cfg b/setup.cfg index 44c9d5183..1330c426a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -191,6 +191,7 @@ jenkins_jobs.wrappers = delivery-pipeline=jenkins_jobs.modules.wrappers:delivery_pipeline env-file=jenkins_jobs.modules.wrappers:env_file exclusion=jenkins_jobs.modules.wrappers:exclusion + inject-ownership-variables=jenkins_jobs.modules.wrappers:inject_ownership_variables inject-passwords=jenkins_jobs.modules.wrappers:inject_passwords inject=jenkins_jobs.modules.wrappers:inject jclouds=jenkins_jobs.modules.wrappers:jclouds diff --git a/tests/wrappers/fixtures/ownership001.xml b/tests/wrappers/fixtures/ownership001.xml new file mode 100644 index 000000000..1ac67c888 --- /dev/null +++ b/tests/wrappers/fixtures/ownership001.xml @@ -0,0 +1,9 @@ + + + + + true + true + + + diff --git a/tests/wrappers/fixtures/ownership001.yaml b/tests/wrappers/fixtures/ownership001.yaml new file mode 100644 index 000000000..94c13faff --- /dev/null +++ b/tests/wrappers/fixtures/ownership001.yaml @@ -0,0 +1,4 @@ +wrappers: + - inject-ownership-variables: + job-variables: true + node-variables: true