From 49a5ea159c489eef5aac1db42b46f51d5171d0c8 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 1 Mar 2016 15:28:50 +0100 Subject: [PATCH] Partial support Yaml Axis Plugin Very basic support for Yaml axis provided by the Yaml Axis Jenkins Plugin: https://wiki.jenkins-ci.org/display/JENKINS/Yaml+Axis+Plugin This patch does not support exclusion which is done in a following change. Change-Id: I7e39382425e53f5e1eb811d21810a72389acea2d --- jenkins_jobs/modules/project_matrix.py | 9 +++++++ tests/general/fixtures/matrix-axis-yaml.xml | 27 ++++++++++++++++++++ tests/general/fixtures/matrix-axis-yaml.yaml | 11 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/general/fixtures/matrix-axis-yaml.xml create mode 100644 tests/general/fixtures/matrix-axis-yaml.yaml diff --git a/jenkins_jobs/modules/project_matrix.py b/jenkins_jobs/modules/project_matrix.py index c46182a91..cd252b62e 100644 --- a/jenkins_jobs/modules/project_matrix.py +++ b/jenkins_jobs/modules/project_matrix.py @@ -34,6 +34,8 @@ The module also supports additional, plugin-defined axes: :jenkins-wiki:`DynamicAxis Plugin ` * GroovyAxis (``groovy``), requires the Jenkins :jenkins-wiki:`GroovyAxis Plugin ` +* YamlAxis (``yaml``), requires the Jenkins + :jenkins-wiki:`Yaml Axis Plugin ` To tie the parent job to a specific node, you should use ``node`` parameter. On a matrix project, this will tie *only* the parent job. To restrict axes @@ -67,6 +69,10 @@ Example: .. literalinclude:: /../../tests/yamlparser/fixtures/project-matrix001.yaml :language: yaml +Example for yaml axis: + + .. literalinclude:: /../../tests/general/fixtures/matrix-axis-yaml.yaml + :language: yaml """ import xml.etree.ElementTree as XML @@ -87,6 +93,7 @@ class Matrix(jenkins_jobs.modules.base.Base): 'python': 'jenkins.plugins.shiningpanda.matrix.PythonAxis', 'tox': 'jenkins.plugins.shiningpanda.matrix.ToxAxis', 'groovy': 'org.jenkinsci.plugins.GroovyAxis', + 'yaml': 'org.jenkinsci.plugins.yamlaxis.YamlAxis', } def root_xml(self, data): @@ -145,6 +152,8 @@ class Matrix(jenkins_jobs.modules.base.Base): command = XML.SubElement(lbl_root, 'groovyString') command.text = axis.get('command') XML.SubElement(lbl_root, 'computedValues').text = '' + elif axis_type == "yaml": + XML.SubElement(v_root, 'string').text = axis.get('filename') else: for v in values: XML.SubElement(v_root, 'string').text = str(v) diff --git a/tests/general/fixtures/matrix-axis-yaml.xml b/tests/general/fixtures/matrix-axis-yaml.xml new file mode 100644 index 000000000..33724b97f --- /dev/null +++ b/tests/general/fixtures/matrix-axis-yaml.xml @@ -0,0 +1,27 @@ + + + + false + + + + + python + + config.yaml + + + + database + + config.yaml + + + + + false + false + false + false + true + diff --git a/tests/general/fixtures/matrix-axis-yaml.yaml b/tests/general/fixtures/matrix-axis-yaml.yaml new file mode 100644 index 000000000..24974c512 --- /dev/null +++ b/tests/general/fixtures/matrix-axis-yaml.yaml @@ -0,0 +1,11 @@ +name: matrix-with-yaml-axis +project-type: matrix +axes: + - axis: + type: yaml + filename: config.yaml + name: python + - axis: + type: yaml + filename: config.yaml + name: database