Update extended_choice_param to use convert_xml()
Change-Id: Ia713a21061d6d6db1d1ac48983a44f6f3ea1cc1d
This commit is contained in:
parent
504f6b78ae
commit
00e2ea35d6
@ -395,29 +395,22 @@ def extended_choice_param(registry, xml_parent, data):
|
||||
:arg str multi-select-delimiter: value between selections when the
|
||||
parameter is a multi-select (optiona, default ',')
|
||||
|
||||
Example:
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude:: \
|
||||
/../../tests/parameters/fixtures/extended-choice-param001.yaml
|
||||
/../../tests/parameters/fixtures/extended-choice-param-minimal.yaml
|
||||
:language: yaml
|
||||
|
||||
Full Example:
|
||||
.. literalinclude:: \
|
||||
/../../tests/parameters/fixtures/extended-choice-param-full.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
pdef = base_param(registry, xml_parent, data, False,
|
||||
'com.cwctravel.hudson.plugins.'
|
||||
'extended__choice__parameter.'
|
||||
'ExtendedChoiceParameterDefinition')
|
||||
XML.SubElement(pdef, 'value').text = data.get('value', '')
|
||||
XML.SubElement(pdef, 'visibleItemCount').text = str(data.get(
|
||||
'visible-items', data.get('visible-item-count', 5)))
|
||||
XML.SubElement(pdef, 'multiSelectDelimiter').text = data.get(
|
||||
'multi-select-delimiter', ',')
|
||||
XML.SubElement(pdef, 'quoteValue').text = str(data.get('quote-value',
|
||||
False)).lower()
|
||||
XML.SubElement(pdef, 'defaultValue').text = data.get(
|
||||
'default-value', '')
|
||||
XML.SubElement(pdef, 'descriptionPropertyValue').text = data.get(
|
||||
'value-description', '')
|
||||
choice = data.get('type', 'single-select')
|
||||
|
||||
choicedict = {'single-select': 'PT_SINGLE_SELECT',
|
||||
'multi-select': 'PT_MULTI_SELECT',
|
||||
'radio': 'PT_RADIO',
|
||||
@ -428,23 +421,22 @@ def extended_choice_param(registry, xml_parent, data):
|
||||
'PT_RADIO': 'PT_RADIO',
|
||||
'PT_CHECKBOX': 'PT_CHECKBOX',
|
||||
'PT_TEXTBOX': 'PT_TEXTBOX'}
|
||||
|
||||
if choice in choicedict:
|
||||
XML.SubElement(pdef, 'type').text = choicedict[choice]
|
||||
else:
|
||||
raise JenkinsJobsException("Type entered is not valid, must be one "
|
||||
"of: single-select, multi-select, radio, "
|
||||
"textbox or checkbox")
|
||||
XML.SubElement(pdef, 'propertyFile').text = data.get('property-file', '')
|
||||
XML.SubElement(pdef, 'propertyKey').text = data.get('property-key', '')
|
||||
XML.SubElement(pdef, 'defaultPropertyFile').text = data.get(
|
||||
'default-property-file', '')
|
||||
XML.SubElement(pdef, 'defaultPropertyKey').text = data.get(
|
||||
'default-property-key', '')
|
||||
XML.SubElement(pdef, 'descriptionPropertyFile').text = data.get(
|
||||
'description-property-file', '')
|
||||
XML.SubElement(pdef, 'descriptionPropertyKey').text = data.get(
|
||||
'description-property-key', '')
|
||||
mapping = [
|
||||
('value', 'value', ''),
|
||||
('visible-items', 'visibleItemCount', 5),
|
||||
('multi-select-delimiter', 'multiSelectDelimiter', ','),
|
||||
('quote-value', 'quoteValue', False),
|
||||
('default-value', 'defaultValue', ''),
|
||||
('value-description', 'descriptionPropertyValue', ''),
|
||||
('type', 'type', 'single-select', choicedict),
|
||||
('property-file', 'propertyFile', ''),
|
||||
('property-key', 'propertyKey', ''),
|
||||
('default-property-file', 'defaultPropertyFile', ''),
|
||||
('default-property-key', 'defaultPropertyKey', ''),
|
||||
('description-property-file', 'descriptionPropertyFile', ''),
|
||||
('description-property-key', 'descriptionPropertyKey', ''),
|
||||
]
|
||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||
|
||||
|
||||
def validating_string_param(registry, xml_parent, data):
|
||||
|
@ -7,7 +7,7 @@
|
||||
<name>OPTIONS</name>
|
||||
<description>Available options</description>
|
||||
<value>OptionA,OptionB,OptionC</value>
|
||||
<visibleItemCount>2</visibleItemCount>
|
||||
<visibleItemCount>5</visibleItemCount>
|
||||
<multiSelectDelimiter>,</multiSelectDelimiter>
|
||||
<quoteValue>false</quoteValue>
|
||||
<defaultValue/>
|
@ -4,5 +4,3 @@ parameters:
|
||||
description: "Available options"
|
||||
type: 'PT_CHECKBOX'
|
||||
value: OptionA,OptionB,OptionC
|
||||
visible-item-count: "2"
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition>
|
||||
<name>OPTIONS</name>
|
||||
<description>Available options</description>
|
||||
<value/>
|
||||
<visibleItemCount>2</visibleItemCount>
|
||||
<multiSelectDelimiter>,</multiSelectDelimiter>
|
||||
<quoteValue>false</quoteValue>
|
||||
<defaultValue>foo</defaultValue>
|
||||
<descriptionPropertyValue>bar1, bar2, bar3</descriptionPropertyValue>
|
||||
<type>PT_SINGLE_SELECT</type>
|
||||
<propertyFile>/home/foo/property.prop</propertyFile>
|
||||
<propertyKey>key</propertyKey>
|
||||
<defaultPropertyFile>/home/property.prop</defaultPropertyFile>
|
||||
<defaultPropertyKey>fookey</defaultPropertyKey>
|
||||
<descriptionPropertyFile>/home/foo/bar.properties</descriptionPropertyFile>
|
||||
<descriptionPropertyKey>bar_desc</descriptionPropertyKey>
|
||||
</com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
@ -1,13 +0,0 @@
|
||||
parameters:
|
||||
- extended-choice:
|
||||
name: OPTIONS
|
||||
description: "Available options"
|
||||
property-file: /home/foo/property.prop
|
||||
property-key: key
|
||||
visible-items: 2
|
||||
default-value: foo
|
||||
default-property-file: /home/property.prop
|
||||
default-property-key: fookey
|
||||
description-property-file: /home/foo/bar.properties
|
||||
description-property-key: bar_desc
|
||||
value-description: bar1, bar2, bar3
|
Loading…
x
Reference in New Issue
Block a user