From aeeaf717844b7da7df85e4823ea91c693e03e774 Mon Sep 17 00:00:00 2001 From: Daniel Danner Date: Mon, 17 Aug 2015 10:11:33 +0200 Subject: Add support for GroovyAxis Change-Id: I8661910761ed2a3faab0dcf021fd23ceb71e150b --- jenkins_jobs/modules/project_matrix.py | 17 ++++++++++---- tests/general/fixtures/matrix-axis005.xml | 30 ++++++++++++++++++++++++ tests/general/fixtures/matrix-axis005.yaml | 12 ++++++++++ tests/yamlparser/fixtures/project-matrix001.xml | 5 ++++ tests/yamlparser/fixtures/project-matrix001.yaml | 4 ++++ 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 tests/general/fixtures/matrix-axis005.xml create mode 100644 tests/general/fixtures/matrix-axis005.yaml diff --git a/jenkins_jobs/modules/project_matrix.py b/jenkins_jobs/modules/project_matrix.py index 29030ace..b22e9ace 100644 --- a/jenkins_jobs/modules/project_matrix.py +++ b/jenkins_jobs/modules/project_matrix.py @@ -28,11 +28,12 @@ internal YAML structure: Requires the Jenkins :jenkins-wiki:`Matrix Project Plugin `. -The module supports also dynamic axis: +The module also supports additional, plugin-defined axes: -* dynamic (``dynamic``) - -Requires the Jenkins :jenkins-wiki:`dynamic axis Plugin `. +* DynamicAxis (``dynamic``), requires the Jenkins + :jenkins-wiki:`DynamicAxis Plugin ` +* GroovyAxis (``groovy``), requires the Jenkins + :jenkins-wiki:`GroovyAxis 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 @@ -85,6 +86,7 @@ class Matrix(jenkins_jobs.modules.base.Base): 'dynamic': 'ca.silvermaplesolutions.jenkins.plugins.daxis.DynamicAxis', 'python': 'jenkins.plugins.shiningpanda.matrix.PythonAxis', 'tox': 'jenkins.plugins.shiningpanda.matrix.ToxAxis', + 'groovy': 'org.jenkinsci.plugins.GroovyAxis', } def root_xml(self, data): @@ -132,12 +134,17 @@ class Matrix(jenkins_jobs.modules.base.Base): XML.SubElement(lbl_root, 'name').text = 'TOXENV' else: XML.SubElement(lbl_root, 'name').text = str(name) - v_root = XML.SubElement(lbl_root, 'values') + if axis_type != "groovy": + v_root = XML.SubElement(lbl_root, 'values') if axis_type == "dynamic": XML.SubElement(v_root, 'string').text = str(values[0]) XML.SubElement(lbl_root, 'varName').text = str(values[0]) v_root = XML.SubElement(lbl_root, 'axisValues') XML.SubElement(v_root, 'string').text = 'default' + elif axis_type == "groovy": + command = XML.SubElement(lbl_root, 'groovyString') + command.text = axis.get('command') + XML.SubElement(lbl_root, 'computedValues').text = '' else: for v in values: XML.SubElement(v_root, 'string').text = str(v) diff --git a/tests/general/fixtures/matrix-axis005.xml b/tests/general/fixtures/matrix-axis005.xml new file mode 100644 index 00000000..69122611 --- /dev/null +++ b/tests/general/fixtures/matrix-axis005.xml @@ -0,0 +1,30 @@ + + + + false + + + + + config + + config_list + + config_list + + default + + + + foo + return [bar,baz] + + + + + false + false + false + false + true + diff --git a/tests/general/fixtures/matrix-axis005.yaml b/tests/general/fixtures/matrix-axis005.yaml new file mode 100644 index 00000000..4be2e77c --- /dev/null +++ b/tests/general/fixtures/matrix-axis005.yaml @@ -0,0 +1,12 @@ +name: matrix-test005 +project-type: matrix +axes: + - axis: + type: dynamic + name: config + values: + - config_list + - axis: + type: groovy + name: foo + command: 'return [bar,baz]' diff --git a/tests/yamlparser/fixtures/project-matrix001.xml b/tests/yamlparser/fixtures/project-matrix001.xml index d32882c8..489d04db 100644 --- a/tests/yamlparser/fixtures/project-matrix001.xml +++ b/tests/yamlparser/fixtures/project-matrix001.xml @@ -50,6 +50,11 @@ sqlite + + foo + return [one,two,three] + + <!-- Managed by Jenkins Job Builder --> diff --git a/tests/yamlparser/fixtures/project-matrix001.yaml b/tests/yamlparser/fixtures/project-matrix001.yaml index dfe28f20..675ca83d 100644 --- a/tests/yamlparser/fixtures/project-matrix001.yaml +++ b/tests/yamlparser/fixtures/project-matrix001.yaml @@ -39,5 +39,9 @@ - mysql - postgresql - sqlite + - axis: + type: groovy + name: foo + command: return [one,two,three] builders: - shell: make && make check -- cgit