matrix project: add support for dynamic axis
This axis requires the dynamic axis plugin: https://wiki.jenkins-ci.org/display/JENKINS/DynamicAxis+Plugin All the dynamic axis plugin settings are in the core project: <matrix-project> <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> </axes> The plugin sets 2 values: axis name and variable name. The axisValue element is hardcoded to 'default' in the plugin, so we do the same in Jenkins job builder. The matrix project supports multiple axes configuration, including dynamic axis. Tests added for: * dynamic axis (by itself) * multiple axes (dynamic and user-defined axes) Tested on Jenkins LTS (1.554.2) with both the plugin installed and not installed. The plugin is properly ignored in the latter case. Change-Id: I36310bc512fd873fec4bd5f42937689fd178536e Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
This commit is contained in:
parent
3696fdaba2
commit
c5d3e71cca
|
@ -24,6 +24,13 @@ internal YAML structure:
|
|||
* user-defined values (``user-defined``)
|
||||
* slave name or label (``slave``)
|
||||
|
||||
The module supports also dynamic axis:
|
||||
|
||||
* dynamic (``dynamic``)
|
||||
|
||||
Requires the Jenkins `dynamic axis Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/DynamicAxis+Plugin>`_
|
||||
|
||||
:Job Parameters:
|
||||
* **execution-strategy** (optional):
|
||||
* **combination-filter** (`str`): axes selection filter
|
||||
|
@ -70,6 +77,11 @@ Example::
|
|||
values:
|
||||
- node1
|
||||
- node2
|
||||
- axis:
|
||||
type: dynamic
|
||||
name: config
|
||||
values:
|
||||
- config_list
|
||||
builders:
|
||||
- shell: make && make check
|
||||
|
||||
|
@ -103,6 +115,7 @@ class Matrix(jenkins_jobs.modules.base.Base):
|
|||
'label-expression': 'hudson.matrix.LabelExpAxis',
|
||||
'user-defined': 'hudson.matrix.TextAxis',
|
||||
'slave': 'hudson.matrix.LabelAxis',
|
||||
'dynamic': 'ca.silvermaplesolutions.jenkins.plugins.daxis.DynamicAxis',
|
||||
}
|
||||
|
||||
def root_xml(self, data):
|
||||
|
@ -143,7 +156,13 @@ class Matrix(jenkins_jobs.modules.base.Base):
|
|||
name, values = axis['name'], axis['values']
|
||||
XML.SubElement(lbl_root, 'name').text = str(name)
|
||||
v_root = XML.SubElement(lbl_root, 'values')
|
||||
for v in values:
|
||||
XML.SubElement(v_root, 'string').text = str(v)
|
||||
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'
|
||||
else:
|
||||
for v in values:
|
||||
XML.SubElement(v_root, 'string').text = str(v)
|
||||
|
||||
return root
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?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>
|
||||
</axes>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</matrix-project>
|
|
@ -0,0 +1,8 @@
|
|||
name: matrix-test001
|
||||
project-type: matrix
|
||||
axes:
|
||||
- axis:
|
||||
type: dynamic
|
||||
name: config
|
||||
values:
|
||||
- config_list
|
|
@ -0,0 +1,32 @@
|
|||
<?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>
|
||||
<hudson.matrix.TextAxis>
|
||||
<name>arch</name>
|
||||
<values>
|
||||
<string>arm64</string>
|
||||
<string>amd64</string>
|
||||
</values>
|
||||
</hudson.matrix.TextAxis>
|
||||
</axes>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</matrix-project>
|
|
@ -0,0 +1,14 @@
|
|||
name: matrix-test002
|
||||
project-type: matrix
|
||||
axes:
|
||||
- axis:
|
||||
type: dynamic
|
||||
name: config
|
||||
values:
|
||||
- config_list
|
||||
- axis:
|
||||
type: user-defined
|
||||
name: arch
|
||||
values:
|
||||
- arm64
|
||||
- amd64
|
Loading…
Reference in New Issue