Adding tests surrounding handling of defaults values

waynr fixed a bug but explained in concat_defaults002
This bug happens when some values are specified in an other defaults
namespace then global.
This causes JJB to fail that its unable to find the required keys
becasue these were not merged correctly

Change-Id: Id0df24ba7cf8281389c2ed7af7ee716047d0e4a5
This commit is contained in:
Richard Pijnenburg 2015-05-26 18:46:57 +02:00
parent 9ecafdc284
commit b56e8812c7
5 changed files with 153 additions and 0 deletions

View File

@ -286,6 +286,11 @@ class YamlParser(object):
'job_builder', 'allow_empty_variables') \
and self.config.getboolean(
'job_builder', 'allow_empty_variables')
for key in template.keys():
if key not in params:
params[key] = template[key]
expanded = deep_format(template, params, allow_empty_variables)
job_name = expanded.get('name')

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>my global description&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>echo 'confVersion: v0.42 &amp; fooVersion: v0.10'</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>my project description&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>echo 'confVersion: v0.50 &amp; fooVersion: v0.10'</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>my project 2 description&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>echo 'confVersion: v0.42 &amp; fooVersion: v0.22'</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

View File

@ -0,0 +1,45 @@
- defaults:
name: global
confversion: 'v0.42'
fooversion: 'v0.10'
description: 'my global description'
- defaults:
name: myproject
confversion: 'v0.50'
description: 'my project description'
- defaults:
name: myproject2
fooversion: 'v0.22'
description: 'my project 2 description'
- project:
name: project
jobs:
- job-group
- job-group:
name: job-group
jobs:
- job-template0
- job-template1
- job-template2
- job-template:
name: job-template0
builders:
- shell: "echo 'confVersion: {confversion} & fooVersion: {fooversion}'"
- job-template:
name: job-template1
defaults: myproject
builders:
- shell: "echo 'confVersion: {confversion} & fooVersion: {fooversion}'"
- job-template:
name: job-template2
defaults: myproject2
builders:
- shell: "echo 'confVersion: {confversion} & fooVersion: {fooversion}'"

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>my project description&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>echo 'confVersion: v0.42 &amp; fooVersion: v0.10'</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

View File

@ -0,0 +1,25 @@
- defaults:
name: global
description: 'my global description'
- defaults:
name: myproject
fooversion: 'v0.10'
confversion: 'v0.42'
description: 'my project description'
- project:
name: project
jobs:
- job-group
- job-group:
name: job-group
jobs:
- job-template
- job-template:
name: job-template
defaults: myproject
builders:
- shell: "echo 'confVersion: {confversion} & fooVersion: {fooversion}'"