Added trim option for String parameter.
Task: #22637 Change-Id: Ic2722aac586d3911e3ff5ab4c2d3c5a7a03fa14e
This commit is contained in:
parent
4e1e1c7524
commit
2eb74a15cd
jenkins_jobs/modules
tests
macros/fixtures/wrapper
parameters
wrappers/fixtures
yamlparser/fixtures
@ -61,6 +61,8 @@ def string_param(registry, xml_parent, data):
|
||||
:arg str name: the name of the parameter
|
||||
:arg str default: the default value of the parameter (optional)
|
||||
:arg str description: a description of the parameter (optional)
|
||||
:arg bool trim: strip whitespaces from the begnning and end
|
||||
of the string (optional, default: false)
|
||||
|
||||
Example::
|
||||
|
||||
@ -69,11 +71,15 @@ def string_param(registry, xml_parent, data):
|
||||
name: FOO
|
||||
default: bar
|
||||
description: "A parameter named FOO, defaults to 'bar'."
|
||||
trim: true
|
||||
"""
|
||||
base_param(
|
||||
pdef = base_param(
|
||||
registry, xml_parent, data, True, "hudson.model.StringParameterDefinition"
|
||||
)
|
||||
|
||||
mapping = [("trim", "trim", False)]
|
||||
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||
|
||||
|
||||
def promoted_param(registry, xml_parent, data):
|
||||
"""yaml: promoted build
|
||||
|
@ -21,6 +21,7 @@
|
||||
<name>RELEASE_BRANCH</name>
|
||||
<description>Git branch to release from.</description>
|
||||
<defaultValue/>
|
||||
<trim>false</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.BooleanParameterDefinition>
|
||||
<name>FOO</name>
|
||||
|
15
tests/parameters/string-param001.xml
Normal file
15
tests/parameters/string-param001.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>FOO</name>
|
||||
<description>A parameter named FOO, defaults to 'bar'.</description>
|
||||
<defaultValue>bar</defaultValue>
|
||||
<trim>false</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
5
tests/parameters/string-param001.yaml
Normal file
5
tests/parameters/string-param001.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
parameters:
|
||||
- string:
|
||||
name: FOO
|
||||
default: bar
|
||||
description: A parameter named FOO, defaults to 'bar'.
|
15
tests/parameters/string-param002.xml
Normal file
15
tests/parameters/string-param002.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>FOO</name>
|
||||
<description>A parameter named FOO, defaults to 'bar'.</description>
|
||||
<defaultValue>bar</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
6
tests/parameters/string-param002.yaml
Normal file
6
tests/parameters/string-param002.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
parameters:
|
||||
- string:
|
||||
name: FOO
|
||||
default: bar
|
||||
description: A parameter named FOO, defaults to 'bar'.
|
||||
trim: true
|
@ -10,6 +10,7 @@
|
||||
<name>RELEASE_BRANCH</name>
|
||||
<description>Git branch to release from.</description>
|
||||
<defaultValue/>
|
||||
<trim>false</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.BooleanParameterDefinition>
|
||||
<name>FOO</name>
|
||||
|
@ -14,6 +14,7 @@
|
||||
<name>INT_DEFAULT</name>
|
||||
<description/>
|
||||
<defaultValue>0</defaultValue>
|
||||
<trim>false</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
@ -39,6 +40,7 @@
|
||||
<name>INT_DEFAULT</name>
|
||||
<description/>
|
||||
<defaultValue>1</defaultValue>
|
||||
<trim>false</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
|
Loading…
Reference in New Issue
Block a user