Add support for GroovyAxis

Change-Id: I8661910761ed2a3faab0dcf021fd23ceb71e150b
This commit is contained in:
Daniel Danner 2015-08-17 10:11:33 +02:00
parent 297078d405
commit aeeaf71784
5 changed files with 63 additions and 5 deletions

View File

@ -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)

View File

@ -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>

View File

@ -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]'

View File

@ -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>

View File

@ -39,5 +39,9 @@
- mysql
- postgresql
- sqlite
- axis:
type: groovy
name: foo
command: return [one,two,three]
builders:
- shell: make && make check