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:
parent
9ecafdc284
commit
b56e8812c7
jenkins_jobs
tests/yamlparser/fixtures
@ -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')
|
||||
|
59
tests/yamlparser/fixtures/concat_defaults001.xml
Normal file
59
tests/yamlparser/fixtures/concat_defaults001.xml
Normal file
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description>my global description<!-- Managed by Jenkins Job Builder --></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 & fooVersion: v0.10'</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description>my project description<!-- Managed by Jenkins Job Builder --></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 & 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<!-- Managed by Jenkins Job Builder --></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 & fooVersion: v0.22'</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
45
tests/yamlparser/fixtures/concat_defaults001.yaml
Normal file
45
tests/yamlparser/fixtures/concat_defaults001.yaml
Normal 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}'"
|
||||
|
19
tests/yamlparser/fixtures/concat_defaults002.xml
Normal file
19
tests/yamlparser/fixtures/concat_defaults002.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description>my project description<!-- Managed by Jenkins Job Builder --></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 & fooVersion: v0.10'</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
25
tests/yamlparser/fixtures/concat_defaults002.yaml
Normal file
25
tests/yamlparser/fixtures/concat_defaults002.yaml
Normal 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}'"
|
Loading…
x
Reference in New Issue
Block a user