summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suvanto <teemu.suvanto@sonymobile.com>2015-01-26 16:25:15 +0100
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-01-29 10:12:27 +0900
commita322faefb7616abb764efd2bc023b2e3325dcc5b (patch)
tree138ed28cfb816b4e5791c6e4c076a00ad2ae01b6
parentcc96136a6e7c4acd6dd08b9a045c07fd7a3fe27c (diff)
downloadpython-jenkins-job-builder-a322faefb7616abb764efd2bc023b2e3325dcc5b.tar.gz
python-jenkins-job-builder-a322faefb7616abb764efd2bc023b2e3325dcc5b.tar.xz
python-jenkins-job-builder-a322faefb7616abb764efd2bc023b2e3325dcc5b.zip
Add support for JDK axis
Axis that selects available JDKs. JDK axis has the same XML structure as other axes; only the element name changes. The matrix project support was split out of core Jenkins into the 'Matrix Project Plugin', so update the docstring to mention that this plugin is required. Tested on Jenkins ver. 1.565.2 with Matrix Project Plugin 1.4. Change-Id: I6b9d243810833bd3d31535439cc48768db5a6598
-rw-r--r--jenkins_jobs/modules/project_matrix.py13
-rw-r--r--tests/general/fixtures/matrix-axis004.xml22
-rw-r--r--tests/general/fixtures/matrix-axis004.yaml8
3 files changed, 40 insertions, 3 deletions
diff --git a/jenkins_jobs/modules/project_matrix.py b/jenkins_jobs/modules/project_matrix.py
index f3b6eb16..9db1aa98 100644
--- a/jenkins_jobs/modules/project_matrix.py
+++ b/jenkins_jobs/modules/project_matrix.py
@@ -17,12 +17,16 @@
The matrix project module handles creating Jenkins matrix
projects. To create a matrix project specify ``matrix`` in the
``project-type`` attribute to the :ref:`Job` definition.
-Currently it only supports three axes which share the same
+Currently it supports four axes which share the same
internal YAML structure:
* label expressions (``label-expression``)
* user-defined values (``user-defined``)
* slave name or label (``slave``)
+* JDK name (``jdk``)
+
+Requires the Jenkins `Matrix Project Plugin.
+<https://wiki.jenkins-ci.org/display/JENKINS/Matrix+Project+Plugin>`_
The module supports also dynamic axis:
@@ -46,7 +50,7 @@ jobs, you can define a single value ``slave`` axis.
* **axes** (`list`):
* **axis**:
* **type** (`str`) -- axis type, must be either
- 'label-expression', 'user-defined' or 'slave'.
+ 'label-expression', 'user-defined', 'slave' or 'jdk'.
* **name** (`str`) -- name of the axis
* **values** (`list`) -- values of the axis
@@ -129,6 +133,7 @@ class Matrix(jenkins_jobs.modules.base.Base):
'label-expression': 'hudson.matrix.LabelExpAxis',
'user-defined': 'hudson.matrix.TextAxis',
'slave': 'hudson.matrix.LabelAxis',
+ 'jdk': 'hudson.matrix.JDKAxis',
'dynamic': 'ca.silvermaplesolutions.jenkins.plugins.daxis.DynamicAxis',
'python': 'jenkins.plugins.shiningpanda.matrix.PythonAxis',
'tox': 'jenkins.plugins.shiningpanda.matrix.ToxAxis',
@@ -171,7 +176,9 @@ class Matrix(jenkins_jobs.modules.base.Base):
axis_name = self.supported_axis.get(axis_type)
lbl_root = XML.SubElement(ax_root, axis_name)
name, values = axis.get('name', ''), axis.get('values', [''])
- if axis_type == 'python':
+ if axis_type == 'jdk':
+ XML.SubElement(lbl_root, 'name').text = 'JDK'
+ elif axis_type == 'python':
XML.SubElement(lbl_root, 'name').text = 'PYTHON'
elif axis_type == 'tox':
XML.SubElement(lbl_root, 'name').text = 'TOXENV'
diff --git a/tests/general/fixtures/matrix-axis004.xml b/tests/general/fixtures/matrix-axis004.xml
new file mode 100644
index 00000000..0f71bdab
--- /dev/null
+++ b/tests/general/fixtures/matrix-axis004.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<matrix-project>
+ <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
+ <runSequentially>false</runSequentially>
+ </executionStrategy>
+ <combinationFilter/>
+ <axes>
+ <hudson.matrix.JDKAxis>
+ <name>JDK</name>
+ <values>
+ <string>openjdk-6-jdk</string>
+ <string>openjdk-7-jdk</string>
+ </values>
+ </hudson.matrix.JDKAxis>
+ </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-axis004.yaml b/tests/general/fixtures/matrix-axis004.yaml
new file mode 100644
index 00000000..674b21bf
--- /dev/null
+++ b/tests/general/fixtures/matrix-axis004.yaml
@@ -0,0 +1,8 @@
+name: matrix-test004
+project-type: matrix
+axes:
+ - axis:
+ type: jdk
+ values:
+ - openjdk-6-jdk
+ - openjdk-7-jdk