Add choice parameter type.

Change-Id: I6675727cd0638a183e20c0110fcdedfdca3f715a
Reviewed-on: https://review.openstack.org/13785
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
James E. Blair 2012-09-27 14:03:44 -07:00 committed by Jenkins
parent c82bf22f79
commit 560954b43f
2 changed files with 29 additions and 0 deletions

View File

@ -47,6 +47,7 @@ def base_param(parser, xml_parent, data, do_default, ptype):
XML.SubElement(pdef, 'defaultValue').text = default
else:
XML.SubElement(pdef, 'defaultValue')
return pdef
def string_param(parser, xml_parent, data):
@ -148,6 +149,33 @@ def label_param(parser, xml_parent, data):
'org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition')
def choice_param(parser, xml_parent, data):
"""yaml: choice
A single selection parameter.
:arg str name: the name of the parameter
:arg list choices: the available choices
:arg str description: a description of the parameter (optional)
Example::
parameters:
- choice:
name: project
choices:
- nova
- glance
description: "On which project to run?"
"""
pdef = base_param(parser, xml_parent, data, False,
'hudson.model.ChoiceParameterDefinition')
choices = XML.SubElement(pdef, 'choices',
{'class': 'java.util.Arrays$ArrayList'})
a = XML.SubElement(choices, 'a', {'class': 'string-array'})
for choice in data['choices']:
XML.SubElement(a, 'string').text = choice
class Parameters(jenkins_jobs.modules.base.Base):
sequence = 21

View File

@ -52,6 +52,7 @@ setup(name='jenkins_job_builder',
'file=jenkins_jobs.modules.parameters:file_param',
'text=jenkins_jobs.modules.parameters:text_param',
'label=jenkins_jobs.modules.parameters:label_param',
'choice=jenkins_jobs.modules.parameters:choice_param',
],
'jenkins_jobs.notifications': [
'http=jenkins_jobs.modules.notifications:http_endpoint',