Support variable-specific substitutions in templates.
Change-Id: I6af84f48eaa4ee44c8d8babddd8d10a1e1095101
This commit is contained in:
parent
07c5bd1cc3
commit
2de0e0e7df
|
@ -167,6 +167,12 @@ values. Example::
|
|||
jobs:
|
||||
- '{name}-{pyver}'
|
||||
|
||||
If there are templates being realized that differ only in the variable
|
||||
used for its name (thus not a use case for job-specific substitutions),
|
||||
additional variables can be specified for project variables. Example::
|
||||
|
||||
.. literalinclude:: /../../tests/yamlparser/fixtures/templates002.yaml
|
||||
|
||||
Job Group
|
||||
^^^^^^^^^
|
||||
|
||||
|
|
|
@ -257,7 +257,17 @@ class YamlParser(object):
|
|||
checksums = set([])
|
||||
for values in itertools.product(*dimensions):
|
||||
params = copy.deepcopy(project)
|
||||
params.update(values)
|
||||
|
||||
expanded_values = {}
|
||||
for (k, v) in values:
|
||||
if isinstance(v, dict):
|
||||
inner_key = v.iterkeys().next()
|
||||
expanded_values[k] = inner_key
|
||||
expanded_values.update(v[inner_key])
|
||||
else:
|
||||
expanded_values[k] = v
|
||||
|
||||
params.update(expanded_values)
|
||||
expanded = deep_format(template, params)
|
||||
|
||||
# Keep track of the resulting expansions to avoid
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?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>git co old_branch</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
||||
<BLANKLINE>
|
||||
<?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>git co new_branch</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
- job-template:
|
||||
name: '{name}-{pyver}'
|
||||
builders:
|
||||
- shell: 'git co {branch_name}'
|
||||
|
||||
- project:
|
||||
name: project-name
|
||||
pyver:
|
||||
- 26:
|
||||
branch_name: old_branch
|
||||
- 27:
|
||||
branch_name: new_branch
|
||||
jobs:
|
||||
- '{name}-{pyver}'
|
Loading…
Reference in New Issue