summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Danner <daniel.danner@methodpark.de>2015-08-17 10:11:33 +0200
committerDaniel Danner <daniel.danner@methodpark.de>2015-08-17 13:24:58 +0200
commitaeeaf717844b7da7df85e4823ea91c693e03e774 (patch)
tree8fb2a84105f3cc1c23bc9f7bcb3df360c107b346
parent297078d405e9fe39568ae1c7c921871f5defe8ad (diff)
downloadpython-jenkins-job-builder-aeeaf717844b7da7df85e4823ea91c693e03e774.tar.gz
python-jenkins-job-builder-aeeaf717844b7da7df85e4823ea91c693e03e774.tar.xz
python-jenkins-job-builder-aeeaf717844b7da7df85e4823ea91c693e03e774.zip
Add support for GroovyAxis
Change-Id: I8661910761ed2a3faab0dcf021fd23ceb71e150b
-rw-r--r--jenkins_jobs/modules/project_matrix.py17
-rw-r--r--tests/general/fixtures/matrix-axis005.xml30
-rw-r--r--tests/general/fixtures/matrix-axis005.yaml12
-rw-r--r--tests/yamlparser/fixtures/project-matrix001.xml5
-rw-r--r--tests/yamlparser/fixtures/project-matrix001.yaml4
5 files changed, 63 insertions, 5 deletions
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
<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+Plugin>`.
+* DynamicAxis (``dynamic``), requires the Jenkins
+ :jenkins-wiki:`DynamicAxis Plugin <DynamicAxis+Plugin>`
+* GroovyAxis (``groovy``), requires the Jenkins
+ :jenkins-wiki:`GroovyAxis Plugin <GroovyAxis>`
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<matrix-project>
+ <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
+ <runSequentially>false</runSequentially>
+ </executionStrategy>
+ <combinationFilter/>
+ <axes>
+ <ca.silvermaplesolutions.jenkins.plugins.daxis.DynamicAxis>
+ <name>config</name>
+ <values>
+ <string>config_list</string>
+ </values>
+ <varName>config_list</varName>
+ <axisValues>
+ <string>default</string>
+ </axisValues>
+ </ca.silvermaplesolutions.jenkins.plugins.daxis.DynamicAxis>
+ <org.jenkinsci.plugins.GroovyAxis>
+ <name>foo</name>
+ <groovyString>return [bar,baz]</groovyString>
+ <computedValues/>
+ </org.jenkinsci.plugins.GroovyAxis>
+ </axes>
+ <actions/>
+ <keepDependencies>false</keepDependencies>
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+ <concurrentBuild>false</concurrentBuild>
+ <canRoam>true</canRoam>
+</matrix-project>
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 @@
<string>sqlite</string>
</values>
</hudson.matrix.TextAxis>
+ <org.jenkinsci.plugins.GroovyAxis>
+ <name>foo</name>
+ <groovyString>return [one,two,three]</groovyString>
+ <computedValues/>
+ </org.jenkinsci.plugins.GroovyAxis>
</axes>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
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