diff options
author | Jonathan Perret <jonathan@ut7.fr> | 2015-10-07 18:17:47 +0200 |
---|---|---|
committer | Jonathan Perret <jonathan@ut7.fr> | 2015-10-09 23:08:11 +0200 |
commit | a63d3c8d117c2f427eb207527af974cfaea6715f (patch) | |
tree | a1ea96d7a8cfa968bd991aecc0e30efaf8559d3e | |
parent | 556deebe25e4a03d2d1b22d54ba6e41fadde8804 (diff) | |
download | python-jenkins-job-builder-a63d3c8d117c2f427eb207527af974cfaea6715f.tar.gz python-jenkins-job-builder-a63d3c8d117c2f427eb207527af974cfaea6715f.tar.xz python-jenkins-job-builder-a63d3c8d117c2f427eb207527af974cfaea6715f.zip |
Allow raw XML at project top-level
This allows a `raw` section at the top-level of a job definition.
Change-Id: Id76bbfbde8df49b221fcd1198354ba8b5ce9fb02
-rw-r--r-- | jenkins_jobs/modules/general.py | 7 | ||||
-rw-r--r-- | tests/general/fixtures/raw-xml-toplevel.xml | 13 | ||||
-rw-r--r-- | tests/general/fixtures/raw-xml-toplevel.yaml | 3 |
3 files changed, 23 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/general.py b/jenkins_jobs/modules/general.py index 51953a26..6248d553 100644 --- a/jenkins_jobs/modules/general.py +++ b/jenkins_jobs/modules/general.py @@ -95,6 +95,10 @@ Example: history. It adds the ``logrotate`` attribute to the :ref:`Job` definition. All logrotate attributes default to "-1" (keep forever). + * **raw**: + If present, this section should contain a single **xml** entry. This XML + will be inserted at the top-level of the :ref:`Job` definition. + """ import xml.etree.ElementTree as XML @@ -171,6 +175,9 @@ class General(jenkins_jobs.modules.base.Base): lr_anum = XML.SubElement(lr_xml, 'artifactNumToKeep') lr_anum.text = str(logrotate.get('artifactNumToKeep', -1)) + if 'raw' in data: + raw(parser, xml, data['raw']) + def raw(parser, xml_parent, data): # documented in definition.rst since includes and docs is not working well diff --git a/tests/general/fixtures/raw-xml-toplevel.xml b/tests/general/fixtures/raw-xml-toplevel.xml new file mode 100644 index 00000000..0893bf54 --- /dev/null +++ b/tests/general/fixtures/raw-xml-toplevel.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <actions/> + <keepDependencies>false</keepDependencies> + <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> + <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> + <concurrentBuild>false</concurrentBuild> + <canRoam>true</canRoam> + <createdByJenkinsAutojobs> + <ref>refs/heads/branch</ref> + <tag>feature</tag> + </createdByJenkinsAutojobs> +</project> diff --git a/tests/general/fixtures/raw-xml-toplevel.yaml b/tests/general/fixtures/raw-xml-toplevel.yaml new file mode 100644 index 00000000..0b3b19d2 --- /dev/null +++ b/tests/general/fixtures/raw-xml-toplevel.yaml @@ -0,0 +1,3 @@ +raw: + xml: | + <createdByJenkinsAutojobs><ref>refs/heads/branch</ref><tag>feature</tag></createdByJenkinsAutojobs> |