Merge "Fix support for !j2-yaml tag on project level (missing deepcopy impl)"
This commit is contained in:
commit
08d69a6594
@ -609,6 +609,9 @@ class LateYamlLoader(CustomLoader):
|
||||
self._yaml_str = yaml_str
|
||||
self._loader = loader
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
return LateYamlLoader(self._yaml_str, copy.deepcopy(self._loader, memo))
|
||||
|
||||
def get_object_to_format(self):
|
||||
return load(self._yaml_str, search_path=self._loader._search_path)
|
||||
|
||||
@ -618,6 +621,9 @@ class Jinja2YamlLoader(Jinja2Loader):
|
||||
yaml_str = super(Jinja2YamlLoader, self).format(**kwargs)
|
||||
return LateYamlLoader(yaml_str, self)
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
return Jinja2YamlLoader(self._contents, self._search_path)
|
||||
|
||||
|
||||
class CustomLoaderCollection(object):
|
||||
"""Helper class to format a collection of CustomLoader objects"""
|
||||
|
38
tests/yamlparser/fixtures/jinja-yaml04-deepcopy.xml
Normal file
38
tests/yamlparser/fixtures/jinja-yaml04-deepcopy.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?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/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo "['repo-1', 'repo-2', 'repo-a1', 'repo-a2']"</command>
|
||||
</hudson.tasks.Shell>
|
||||
</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/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>echo "['repo-1', 'repo-2', 'repo-b1', 'repo-b2']"</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
28
tests/yamlparser/fixtures/jinja-yaml04-deepcopy.yaml
Normal file
28
tests/yamlparser/fixtures/jinja-yaml04-deepcopy.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
- job-template:
|
||||
name: 'test-job-template-{variant}'
|
||||
builders:
|
||||
- shell:
|
||||
echo "{repos}"
|
||||
|
||||
- project:
|
||||
name: test-project
|
||||
repos_common:
|
||||
- repo-1
|
||||
- repo-2
|
||||
jobs:
|
||||
- 'test-job-template-{variant}':
|
||||
variant: 'a'
|
||||
repos: !j2-yaml: |
|
||||
{% for repo in repos_common %}
|
||||
- {{ repo }}
|
||||
{% endfor %}
|
||||
- repo-a1
|
||||
- repo-a2
|
||||
- 'test-job-template-{variant}':
|
||||
variant: 'b'
|
||||
repos: !j2-yaml: |
|
||||
{% for repo in repos_common %}
|
||||
- {{ repo }}
|
||||
{% endfor %}
|
||||
- repo-b1
|
||||
- repo-b2
|
Loading…
x
Reference in New Issue
Block a user