diff --git a/jenkins_jobs/modules/parameters.py b/jenkins_jobs/modules/parameters.py index fca02e1c2..37030617f 100644 --- a/jenkins_jobs/modules/parameters.py +++ b/jenkins_jobs/modules/parameters.py @@ -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 diff --git a/tests/macros/fixtures/wrapper/release_inner-macro-expansion-001.xml b/tests/macros/fixtures/wrapper/release_inner-macro-expansion-001.xml index f6fe354e7..d3cf435a5 100644 --- a/tests/macros/fixtures/wrapper/release_inner-macro-expansion-001.xml +++ b/tests/macros/fixtures/wrapper/release_inner-macro-expansion-001.xml @@ -21,6 +21,7 @@ RELEASE_BRANCH Git branch to release from. + false FOO diff --git a/tests/parameters/string-param001.xml b/tests/parameters/string-param001.xml new file mode 100644 index 000000000..39e81402d --- /dev/null +++ b/tests/parameters/string-param001.xml @@ -0,0 +1,15 @@ + + + + + + + FOO + A parameter named FOO, defaults to 'bar'. + bar + false + + + + + diff --git a/tests/parameters/string-param001.yaml b/tests/parameters/string-param001.yaml new file mode 100644 index 000000000..b63de8e46 --- /dev/null +++ b/tests/parameters/string-param001.yaml @@ -0,0 +1,5 @@ +parameters: + - string: + name: FOO + default: bar + description: A parameter named FOO, defaults to 'bar'. diff --git a/tests/parameters/string-param002.xml b/tests/parameters/string-param002.xml new file mode 100644 index 000000000..7300cebfc --- /dev/null +++ b/tests/parameters/string-param002.xml @@ -0,0 +1,15 @@ + + + + + + + FOO + A parameter named FOO, defaults to 'bar'. + bar + true + + + + + diff --git a/tests/parameters/string-param002.yaml b/tests/parameters/string-param002.yaml new file mode 100644 index 000000000..4c93586ea --- /dev/null +++ b/tests/parameters/string-param002.yaml @@ -0,0 +1,6 @@ +parameters: + - string: + name: FOO + default: bar + description: A parameter named FOO, defaults to 'bar'. + trim: true diff --git a/tests/wrappers/fixtures/release001.xml b/tests/wrappers/fixtures/release001.xml index 78af55cb3..db64b5d3d 100644 --- a/tests/wrappers/fixtures/release001.xml +++ b/tests/wrappers/fixtures/release001.xml @@ -10,6 +10,7 @@ RELEASE_BRANCH Git branch to release from. + false FOO diff --git a/tests/yamlparser/fixtures/variable_default_values.xml b/tests/yamlparser/fixtures/variable_default_values.xml index a051363d9..61119939c 100644 --- a/tests/yamlparser/fixtures/variable_default_values.xml +++ b/tests/yamlparser/fixtures/variable_default_values.xml @@ -14,6 +14,7 @@ INT_DEFAULT 0 + false @@ -39,6 +40,7 @@ INT_DEFAULT 1 + false