Add support for 'All Nodes For Label Factory'
Gives ability to trigger a build of a project on all nodes with specific label. Requires NodeLabel Parameter plugin. Change-Id: I1a59c7c27591574bb1c1af0041de7cfd3775916d
This commit is contained in:
parent
4bf020e07e
commit
9039eaa09b
@ -325,6 +325,16 @@ def trigger_builds(parser, xml_parent, data):
|
||||
['FAIL', 'SKIP', 'NOPARMS']
|
||||
(default 'FAIL')
|
||||
|
||||
:Factory: * **factory** (`str`) **allnodesforlabel** -- Trigger a build
|
||||
on all nodes having specific label. Requires NodeLabel
|
||||
Parameter Plugin (optional)
|
||||
* **name** (`str`) -- Name of the parameter to set (optional)
|
||||
* **node-label** (`str`) -- Label of the nodes where build
|
||||
should be triggered
|
||||
* **ignore-offline-nodes** (`bool`) -- Don't trigger build on
|
||||
offline nodes (optional)
|
||||
(default true)
|
||||
|
||||
Examples:
|
||||
|
||||
Basic usage.
|
||||
@ -385,7 +395,10 @@ def trigger_builds(parser, xml_parent, data):
|
||||
if 'parameter-factories' in project_def:
|
||||
fconfigs = XML.SubElement(tconfig, 'configFactories')
|
||||
|
||||
supported_factories = ['filebuild', 'binaryfile', 'counterbuild']
|
||||
supported_factories = ['filebuild',
|
||||
'binaryfile',
|
||||
'counterbuild',
|
||||
'allnodesforlabel']
|
||||
supported_actions = ['SKIP', 'NOPARMS', 'FAIL']
|
||||
for factory in project_def['parameter-factories']:
|
||||
|
||||
@ -441,6 +454,22 @@ def trigger_builds(parser, xml_parent, data):
|
||||
"validation-fail action must be one of %s" %
|
||||
", ".join(supported_actions))
|
||||
validationFail.text = validationFailValue
|
||||
if factory['factory'] == 'allnodesforlabel':
|
||||
params = XML.SubElement(
|
||||
fconfigs,
|
||||
'org.jvnet.jenkins.plugins.nodelabelparameter.'
|
||||
'parameterizedtrigger.'
|
||||
'AllNodesForLabelBuildParameterFactory')
|
||||
nameProperty = XML.SubElement(params, 'name')
|
||||
nameProperty.text = str(factory.get(
|
||||
'name', ''))
|
||||
nodeLabel = XML.SubElement(params, 'nodeLabel')
|
||||
nodeLabel.text = str(factory['node-label'])
|
||||
ignoreOfflineNodes = XML.SubElement(
|
||||
params,
|
||||
'ignoreOfflineNodes')
|
||||
ignoreOfflineNodes.text = str(factory.get(
|
||||
'ignore-offline-nodes', True)).lower()
|
||||
|
||||
projects = XML.SubElement(tconfig, 'projects')
|
||||
projects.text = project_def['project']
|
||||
|
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
<configs class="java.util.Collections$EmptyList"/>
|
||||
<configFactories>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory>
|
||||
<name>test-name</name>
|
||||
<nodeLabel>test-label</nodeLabel>
|
||||
<ignoreOfflineNodes>true</ignoreOfflineNodes>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory>
|
||||
</configFactories>
|
||||
<projects>build_started</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
<buildAllNodesWithLabel>false</buildAllNodesWithLabel>
|
||||
<block>
|
||||
<buildStepFailureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
</configs>
|
||||
</hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,9 @@
|
||||
builders:
|
||||
- trigger-builds:
|
||||
- project: "build_started"
|
||||
parameter-factories:
|
||||
- factory: allnodesforlabel
|
||||
name: test-name
|
||||
node-label: test-label
|
||||
ignore-offline-nodes: true
|
||||
block: true
|
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
<configs class="java.util.Collections$EmptyList"/>
|
||||
<configFactories>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory>
|
||||
<name/>
|
||||
<nodeLabel>test-label</nodeLabel>
|
||||
<ignoreOfflineNodes>true</ignoreOfflineNodes>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory>
|
||||
</configFactories>
|
||||
<projects>build_started</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
<buildAllNodesWithLabel>false</buildAllNodesWithLabel>
|
||||
<block>
|
||||
<buildStepFailureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
</configs>
|
||||
</hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
builders:
|
||||
- trigger-builds:
|
||||
- project: "build_started"
|
||||
parameter-factories:
|
||||
- factory: allnodesforlabel
|
||||
node-label: test-label
|
||||
block: true
|
@ -28,6 +28,11 @@
|
||||
<paramExpr/>
|
||||
<validationFail>FAIL</validationFail>
|
||||
</hudson.plugins.parameterizedtrigger.CounterBuildParameterFactory>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory>
|
||||
<name>parametername</name>
|
||||
<nodeLabel>labelname</nodeLabel>
|
||||
<ignoreOfflineNodes>false</ignoreOfflineNodes>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory>
|
||||
</configFactories>
|
||||
<projects>build_started</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
|
@ -15,4 +15,8 @@ builders:
|
||||
from: 0
|
||||
to: 5
|
||||
step: 1
|
||||
- factory: allnodesforlabel
|
||||
name: parametername
|
||||
node-label: labelname
|
||||
ignore-offline-nodes: false
|
||||
block: true
|
||||
|
Loading…
Reference in New Issue
Block a user