Fix default '0' being ignored
The problem with `if default:` is that it evaluates int 0 to be equivalent to False. If a user is passing in a int 0 then they should be expected to receive int 0 in the case of defaults. Change-Id: Ida1f4c68b6f9d1af5b98d633b552f038c57654cc Signed-off-by: Thanh Ha <zxiiro@linux.com>
This commit is contained in:
parent
d15e57a14a
commit
02e85408f0
@ -47,7 +47,7 @@ def base_param(registry, xml_parent, data, do_default, ptype):
|
||||
XML.SubElement(pdef, 'description').text = data.get('description', '')
|
||||
if do_default:
|
||||
default = data.get('default', None)
|
||||
if default:
|
||||
if default is not None:
|
||||
XML.SubElement(pdef, 'defaultValue').text = str(default)
|
||||
else:
|
||||
XML.SubElement(pdef, 'defaultValue')
|
||||
|
@ -1,4 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>INT_DEFAULT</name>
|
||||
<description/>
|
||||
<defaultValue>0</defaultValue>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>INT_DEFAULT</name>
|
||||
<description/>
|
||||
<defaultValue>1</defaultValue>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
|
@ -3,6 +3,10 @@
|
||||
jobs:
|
||||
- 'variable_default_values':
|
||||
defined_var: '7'
|
||||
- 'test_int_default_{int}':
|
||||
int: 0
|
||||
- 'test_int_default_{int}':
|
||||
int: 1
|
||||
|
||||
- job-template:
|
||||
name: 'variable_default_values'
|
||||
@ -18,3 +22,10 @@
|
||||
echo "{{defined_var|-1}}"
|
||||
echo "{{undefined_var|+1}}"
|
||||
echo "{{undefined_var|-1}}"
|
||||
|
||||
- job-template:
|
||||
name: 'test_int_default_{int}'
|
||||
parameters:
|
||||
- string:
|
||||
name: INT_DEFAULT
|
||||
default: '{int}'
|
||||
|
Loading…
x
Reference in New Issue
Block a user