Add support to configure boolean parameter in PBT

This change adds support to the Parameterized Build Trigger plugin for
configuring boolean parameters.

Change-Id: I797fe298248c2737095b39820382a8610a102d87
Also-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Kyle Rockman <kyle.rockman@mac.com>
This commit is contained in:
Kyle Rockman 2015-01-12 16:31:24 -06:00 committed by Thanh Ha
parent 6d33d3c228
commit dfce2400bb
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
3 changed files with 41 additions and 0 deletions

View File

@ -285,6 +285,11 @@ def trigger_builds(parser, xml_parent, data):
:arg str project: the Jenkins project to trigger
:arg str predefined-parameters:
key/value pairs to be passed to the job (optional)
:arg list bool-parameters:
:Bool: * **name** (`str`) -- Parameter name
* **value** (`bool`) -- Value to set (default false)
:arg str property-file:
Pass properties from file to the other job (optional)
:arg bool property-file-fail-on-missing:
@ -400,6 +405,20 @@ def trigger_builds(parser, xml_parent, data):
'PredefinedBuildParameters')
properties = XML.SubElement(params, 'properties')
properties.text = project_def['predefined-parameters']
if 'bool-parameters' in project_def:
params = XML.SubElement(tconfigs,
'hudson.plugins.parameterizedtrigger.'
'BooleanParameters')
configs = XML.SubElement(params, 'configs')
for bool_param in project_def['bool-parameters']:
param = XML.SubElement(configs,
'hudson.plugins.parameterizedtrigger.'
'BooleanParameterConfig')
XML.SubElement(param, 'name').text = str(bool_param['name'])
XML.SubElement(param, 'value').text = str(
bool_param.get('value', False)).lower()
if(len(list(tconfigs)) == 0):
tconfigs.set('class', 'java.util.Collections$EmptyList')

View File

@ -9,6 +9,22 @@
<hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
<properties>FOO=&quot;bar&quot;</properties>
</hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
<hudson.plugins.parameterizedtrigger.BooleanParameters>
<configs>
<hudson.plugins.parameterizedtrigger.BooleanParameterConfig>
<name>PARAM1</name>
<value>false</value>
</hudson.plugins.parameterizedtrigger.BooleanParameterConfig>
<hudson.plugins.parameterizedtrigger.BooleanParameterConfig>
<name>PARAM2</name>
<value>true</value>
</hudson.plugins.parameterizedtrigger.BooleanParameterConfig>
<hudson.plugins.parameterizedtrigger.BooleanParameterConfig>
<name>PARAM3</name>
<value>false</value>
</hudson.plugins.parameterizedtrigger.BooleanParameterConfig>
</configs>
</hudson.plugins.parameterizedtrigger.BooleanParameters>
</configs>
<projects>build_started</projects>
<condition>ALWAYS</condition>

View File

@ -3,5 +3,11 @@ builders:
- project: "build_started"
predefined-parameters:
FOO="bar"
bool-parameters:
- name: "PARAM1"
value: false
- name: "PARAM2"
value: true
- name: "PARAM3"
block: true
same-node: true