Adding extended-choice functionality
This change adds the ability to use the extended choice plugin. This plugin allows you to populate a file with choices and then allow the user to select one or more when the build now button is clicked. This change only changes the properties and setup files. Change-Id: I05af63f75f9ab87cd923c23177d33898c26149cf Reviewed-on: https://review.openstack.org/20610 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Reviewed-by: Jeremy Stanley <fungi@yuggoth.org> Reviewed-by: Khai Do <zaro0508@gmail.com> Approved: Monty Taylor <mordred@inaugust.com> Reviewed-by: Monty Taylor <mordred@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
f05ed7c0ae
commit
4cc4634612
@ -227,6 +227,81 @@ def authorization(parser, xml_parent, data):
|
||||
pe.text = "{0}:{1}".format(mapping[perm], username)
|
||||
|
||||
|
||||
def extended_choice(parser, xml_parent, data):
|
||||
"""yaml: extended-choice
|
||||
Creates an extended choice property where values can be read from a file
|
||||
Requires the Jenkins `Extended Choice Parameter Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/
|
||||
Extended+Choice+Parameter+plugin>`_
|
||||
|
||||
:arg string name: name of the property
|
||||
:arg string description: description of the property (optional, default '')
|
||||
:arg string property-file: location of property file to read from
|
||||
(optional, default '')
|
||||
:arg string property-key: key for the property-file (optional, default '')
|
||||
:arg bool quote-value: whether to put quotes around the property
|
||||
when passing to Jenkins (optional, default false)
|
||||
:arg string visible-items: number of items to show in the list
|
||||
(optional, default 5)
|
||||
:arg string type: type of select (optional, default single-select)
|
||||
:arg string value: comma separated list of values for the single select
|
||||
or multi-select box (optional, default '')
|
||||
:arg string default-value: used to set the initial selection of the
|
||||
single-select or multi-select box (optional, default '')
|
||||
:arg string default-property-file: location of property file when default
|
||||
value needs to come from a property file (optional, default '')
|
||||
:arg string default-property-key: key for the default property file
|
||||
(optional, default '')
|
||||
|
||||
Example::
|
||||
|
||||
properties:
|
||||
- extended-choice:
|
||||
name: FOO
|
||||
description: A foo property
|
||||
property-file: /home/foo/property.prop
|
||||
property-key: key
|
||||
quote-value: true
|
||||
visible-items: 10
|
||||
type: multi-select
|
||||
value: foo,bar,select
|
||||
default-value: foo
|
||||
default-property-file: /home/property.prop
|
||||
default-property-key: fookey
|
||||
"""
|
||||
definition = XML.SubElement(xml_parent,
|
||||
'hudson.model.ParametersDefinitionProperty')
|
||||
definitions = XML.SubElement(definition, 'parameterDefinitions')
|
||||
extended = XML.SubElement(definitions, 'com.cwctravel.hudson.plugins.'
|
||||
'extended__choice__parameter.'
|
||||
'ExtendedChoiceParameterDefinition')
|
||||
XML.SubElement(extended, 'name').text = data['name']
|
||||
XML.SubElement(extended, 'description').text = data.get('description', '')
|
||||
XML.SubElement(extended, 'quoteValue').text = str(data.get('quote-value',
|
||||
'false')).lower()
|
||||
XML.SubElement(extended, 'visibleItemCount').text = data.get(
|
||||
'visible-items', '5')
|
||||
choice = data.get('type', 'single-select')
|
||||
choicedict = {'single-select': 'PT_SINGLE_SELECT',
|
||||
'multi-select': 'PT_MULTI_SELECT',
|
||||
'radio': 'PT_RADIO',
|
||||
'checkbox': 'PT_CHECKBOX'}
|
||||
if choice not in choicedict:
|
||||
raise Exception("Type entered is not valid, must be one of: " +
|
||||
"single-select, multi-select, radio, or checkbox")
|
||||
XML.SubElement(extended, 'type').text = choicedict[choice]
|
||||
XML.SubElement(extended, 'value').text = data.get('value', '')
|
||||
XML.SubElement(extended, 'propertyFile').text = data.get('property-file',
|
||||
'')
|
||||
XML.SubElement(extended, 'propertyKey').text = data.get('property-key', '')
|
||||
XML.SubElement(extended, 'defaultValue').text = data.get('default-value',
|
||||
'')
|
||||
XML.SubElement(extended, 'defaultPropertyFile').text = data.get(
|
||||
'default-property-file', '')
|
||||
XML.SubElement(extended, 'defaultPropertyKey').text = data.get(
|
||||
'default-property-key', '')
|
||||
|
||||
|
||||
class Properties(jenkins_jobs.modules.base.Base):
|
||||
sequence = 20
|
||||
|
||||
|
1
setup.py
1
setup.py
@ -75,6 +75,7 @@ setuptools.setup(
|
||||
'authenticated-build=jenkins_jobs.modules.properties:'
|
||||
'authenticated_build',
|
||||
'authorization=jenkins_jobs.modules.properties:authorization',
|
||||
'extended-choice=jenkins_jobs.modules.properties:extended_choice',
|
||||
],
|
||||
'jenkins_jobs.parameters': [
|
||||
'string=jenkins_jobs.modules.parameters:string_param',
|
||||
|
Loading…
x
Reference in New Issue
Block a user