Add support for the NodeLabel Parameter plugin
Add support for using the NodeLabel Parameter plugin to specify which node should run a job when triggering a parameterized build. Requires the Jenkins NodeLabel Parameter Plugin: https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin Change-Id: Ie947a2a3069b477419db7eaa35307088712467e3
This commit is contained in:
parent
1db5ad59c1
commit
2f6ac5781e
@ -161,6 +161,11 @@ def trigger_parameterized_builds(parser, xml_parent, data):
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/
|
||||
Parameterized+Trigger+Plugin>`_
|
||||
|
||||
Use of the `node-label-name` or `node-label` parameters
|
||||
requires the Jenkins `NodeLabel Parameter Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+P
|
||||
lugin>`_
|
||||
|
||||
:arg str project: name of the job to trigger
|
||||
:arg str predefined-parameters: parameters to pass to the other
|
||||
job (optional)
|
||||
@ -174,21 +179,15 @@ def trigger_parameterized_builds(parser, xml_parent, data):
|
||||
if any of the files are not found in the workspace (default 'False')
|
||||
:arg str restrict-matrix-project: Filter that restricts the subset
|
||||
of the combinations that the downstream project will run (optional)
|
||||
:arg str node-label-name: Specify the Name for the NodeLabel parameter.
|
||||
(optional)
|
||||
:arg str node-label: Specify the Node for the NodeLabel parameter.
|
||||
(optional)
|
||||
|
||||
Example::
|
||||
Example:
|
||||
|
||||
publishers:
|
||||
- trigger-parameterized-builds:
|
||||
- project: other_job, foo, bar
|
||||
predefined-parameters: foo=bar
|
||||
- project: other_job1, other_job2
|
||||
predefined-parameters: BUILD_NUM=${BUILD_NUMBER}
|
||||
property-file: version.prop
|
||||
fail-on-missing: true
|
||||
- project: yet_another_job
|
||||
predefined-parameters: foo=bar
|
||||
git-revision: true
|
||||
restrict-matrix-project: label=="x86"
|
||||
.. literalinclude::
|
||||
/../../tests/publishers/fixtures/trigger_parameterized_builds001.yaml
|
||||
|
||||
"""
|
||||
tbuilder = XML.SubElement(xml_parent,
|
||||
@ -205,7 +204,9 @@ def trigger_parameterized_builds(parser, xml_parent, data):
|
||||
or 'property-file' in project_def
|
||||
or 'current-parameters' in project_def
|
||||
or 'svn-revision' in project_def
|
||||
or 'restrict-matrix-project' in project_def):
|
||||
or 'restrict-matrix-project' in project_def
|
||||
or 'node-label-name' in project_def
|
||||
or 'node-label' in project_def):
|
||||
|
||||
if 'predefined-parameters' in project_def:
|
||||
params = XML.SubElement(tconfigs,
|
||||
@ -245,6 +246,19 @@ def trigger_parameterized_builds(parser, xml_parent, data):
|
||||
'matrix.MatrixSubsetBuildParameters')
|
||||
XML.SubElement(subset, 'filter').text = \
|
||||
project_def['restrict-matrix-project']
|
||||
if 'node-label-name' in project_def or \
|
||||
'node-label' in project_def:
|
||||
params = XML.SubElement(tconfigs,
|
||||
'org.jvnet.jenkins.plugins.'
|
||||
'nodelabelparameter.'
|
||||
'parameterizedtrigger.'
|
||||
'NodeLabelBuildParameter')
|
||||
name = XML.SubElement(params, 'name')
|
||||
if 'node-label-name' in project_def:
|
||||
name.text = project_def['node-label-name']
|
||||
label = XML.SubElement(params, 'nodeLabel')
|
||||
if 'node-label' in project_def:
|
||||
label.text = project_def['node-label']
|
||||
else:
|
||||
tconfigs.set('class', 'java.util.Collections$EmptyList')
|
||||
projects = XML.SubElement(tconfig, 'projects')
|
||||
|
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTrigger>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
||||
<properties>foo=bar</properties>
|
||||
</hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
||||
</configs>
|
||||
<projects>other_job, foo, bar</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
||||
<properties>BUILD_NUM=${BUILD_NUMBER}</properties>
|
||||
</hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
||||
<hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<propertiesFile>version.prop</propertiesFile>
|
||||
<failTriggerOnMissing>true</failTriggerOnMissing>
|
||||
</hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
</configs>
|
||||
<projects>other_job1, other_job2</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
||||
<properties>foo=bar</properties>
|
||||
</hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
|
||||
<hudson.plugins.git.GitRevisionBuildParameters>
|
||||
<combineQueuedCommits>false</combineQueuedCommits>
|
||||
</hudson.plugins.git.GitRevisionBuildParameters>
|
||||
<hudson.plugins.parameterizedtrigger.matrix.MatrixSubsetBuildParameters>
|
||||
<filter>label=="x86"</filter>
|
||||
</hudson.plugins.parameterizedtrigger.matrix.MatrixSubsetBuildParameters>
|
||||
</configs>
|
||||
<projects>yet_another_job</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
<name>foo</name>
|
||||
<nodeLabel/>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
</configs>
|
||||
<projects>yet_another_job_2</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
<name/>
|
||||
<nodeLabel>node-label-foo || node-label-bar</nodeLabel>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
</configs>
|
||||
<projects>yet_another_job_3</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
</configs>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTrigger>
|
||||
</publishers>
|
||||
</project>
|
||||
|
@ -0,0 +1,16 @@
|
||||
publishers:
|
||||
- trigger-parameterized-builds:
|
||||
- project: other_job, foo, bar
|
||||
predefined-parameters: foo=bar
|
||||
- project: other_job1, other_job2
|
||||
predefined-parameters: BUILD_NUM=${BUILD_NUMBER}
|
||||
property-file: version.prop
|
||||
fail-on-missing: true
|
||||
- project: yet_another_job
|
||||
predefined-parameters: foo=bar
|
||||
git-revision: true
|
||||
restrict-matrix-project: label=="x86"
|
||||
- project: yet_another_job_2
|
||||
node-label-name: foo
|
||||
- project: yet_another_job_3
|
||||
node-label: node-label-foo || node-label-bar
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTrigger>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
<name>NodeLabelName</name>
|
||||
<nodeLabel>NodeLabelNode</nodeLabel>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
</configs>
|
||||
<projects>test-project-all</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
<name>NodeLabelName</name>
|
||||
<nodeLabel/>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
</configs>
|
||||
<projects>test-project-just-name</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
<configs>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
<name/>
|
||||
<nodeLabel>NodeLabelNode || NodeBar</nodeLabel>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter>
|
||||
</configs>
|
||||
<projects>test-project-just-node</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
|
||||
</configs>
|
||||
</hudson.plugins.parameterizedtrigger.BuildTrigger>
|
||||
</publishers>
|
||||
</project>
|
||||
|
@ -0,0 +1,9 @@
|
||||
publishers:
|
||||
- trigger-parameterized-builds:
|
||||
- project: 'test-project-all'
|
||||
node-label-name: NodeLabelName
|
||||
node-label: NodeLabelNode
|
||||
- project: 'test-project-just-name'
|
||||
node-label-name: NodeLabelName
|
||||
- project: 'test-project-just-node'
|
||||
node-label: NodeLabelNode || NodeBar
|
Loading…
Reference in New Issue
Block a user