summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jenkins_jobs/modules/parameters.py2
-rw-r--r--tests/yamlparser/fixtures/variable_default_values.xml50
-rw-r--r--tests/yamlparser/fixtures/variable_default_values.yaml11
3 files changed, 62 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/parameters.py b/jenkins_jobs/modules/parameters.py
index 38001b4..3cd8ff7 100644
--- a/jenkins_jobs/modules/parameters.py
+++ b/jenkins_jobs/modules/parameters.py
@@ -47,7 +47,7 @@ def base_param(registry, xml_parent, data, do_default, ptype):
47 XML.SubElement(pdef, 'description').text = data.get('description', '') 47 XML.SubElement(pdef, 'description').text = data.get('description', '')
48 if do_default: 48 if do_default:
49 default = data.get('default', None) 49 default = data.get('default', None)
50 if default: 50 if default is not None:
51 XML.SubElement(pdef, 'defaultValue').text = str(default) 51 XML.SubElement(pdef, 'defaultValue').text = str(default)
52 else: 52 else:
53 XML.SubElement(pdef, 'defaultValue') 53 XML.SubElement(pdef, 'defaultValue')
diff --git a/tests/yamlparser/fixtures/variable_default_values.xml b/tests/yamlparser/fixtures/variable_default_values.xml
index 0346f9e..a051363 100644
--- a/tests/yamlparser/fixtures/variable_default_values.xml
+++ b/tests/yamlparser/fixtures/variable_default_values.xml
@@ -8,6 +8,56 @@
8 <concurrentBuild>false</concurrentBuild> 8 <concurrentBuild>false</concurrentBuild>
9 <canRoam>true</canRoam> 9 <canRoam>true</canRoam>
10 <properties> 10 <properties>
11 <hudson.model.ParametersDefinitionProperty>
12 <parameterDefinitions>
13 <hudson.model.StringParameterDefinition>
14 <name>INT_DEFAULT</name>
15 <description/>
16 <defaultValue>0</defaultValue>
17 </hudson.model.StringParameterDefinition>
18 </parameterDefinitions>
19 </hudson.model.ParametersDefinitionProperty>
20 </properties>
21 <scm class="hudson.scm.NullSCM"/>
22 <builders/>
23 <publishers/>
24 <buildWrappers/>
25</project>
26<?xml version="1.0" encoding="utf-8"?>
27<project>
28 <actions/>
29 <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
30 <keepDependencies>false</keepDependencies>
31 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
32 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
33 <concurrentBuild>false</concurrentBuild>
34 <canRoam>true</canRoam>
35 <properties>
36 <hudson.model.ParametersDefinitionProperty>
37 <parameterDefinitions>
38 <hudson.model.StringParameterDefinition>
39 <name>INT_DEFAULT</name>
40 <description/>
41 <defaultValue>1</defaultValue>
42 </hudson.model.StringParameterDefinition>
43 </parameterDefinitions>
44 </hudson.model.ParametersDefinitionProperty>
45 </properties>
46 <scm class="hudson.scm.NullSCM"/>
47 <builders/>
48 <publishers/>
49 <buildWrappers/>
50</project>
51<?xml version="1.0" encoding="utf-8"?>
52<project>
53 <actions/>
54 <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
55 <keepDependencies>false</keepDependencies>
56 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
57 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
58 <concurrentBuild>false</concurrentBuild>
59 <canRoam>true</canRoam>
60 <properties>
11 <jenkins.model.BuildDiscarderProperty> 61 <jenkins.model.BuildDiscarderProperty>
12 <strategy class="hudson.tasks.LogRotator"> 62 <strategy class="hudson.tasks.LogRotator">
13 <daysToKeep>+1</daysToKeep> 63 <daysToKeep>+1</daysToKeep>
diff --git a/tests/yamlparser/fixtures/variable_default_values.yaml b/tests/yamlparser/fixtures/variable_default_values.yaml
index 7414cfe..3f98bec 100644
--- a/tests/yamlparser/fixtures/variable_default_values.yaml
+++ b/tests/yamlparser/fixtures/variable_default_values.yaml
@@ -3,6 +3,10 @@
3 jobs: 3 jobs:
4 - 'variable_default_values': 4 - 'variable_default_values':
5 defined_var: '7' 5 defined_var: '7'
6 - 'test_int_default_{int}':
7 int: 0
8 - 'test_int_default_{int}':
9 int: 1
6 10
7- job-template: 11- job-template:
8 name: 'variable_default_values' 12 name: 'variable_default_values'
@@ -18,3 +22,10 @@
18 echo "{{defined_var|-1}}" 22 echo "{{defined_var|-1}}"
19 echo "{{undefined_var|+1}}" 23 echo "{{undefined_var|+1}}"
20 echo "{{undefined_var|-1}}" 24 echo "{{undefined_var|-1}}"
25
26- job-template:
27 name: 'test_int_default_{int}'
28 parameters:
29 - string:
30 name: INT_DEFAULT
31 default: '{int}'