use {obj:key} as a way to pass an object and not only strings to templates
As mentioned at the mail list[0]: "So I need another way how to pass a *list* as data structure from the defaults/project down to the job-template definition, similar to what can be done with "{variable}" for strings." [0] http://lists.openstack.org/pipermail/openstack-infra/2014-February/000799.html Closes-Bug: 1281038 Change-Id: I5b04ddb52e537fedd2d05795e91011afd92f2295
This commit is contained in:
parent
14d9686734
commit
673454debd
@ -123,6 +123,12 @@ define a template that you can use to create jobs with a `Project`_
|
||||
definition. It's name will depend on what is supplied to the
|
||||
`Project`_.
|
||||
|
||||
If you want to use lists or dicts variables you can use ``{obj:key}``.
|
||||
|
||||
For example:
|
||||
|
||||
.. literalinclude:: /../../tests/yamlparser/fixtures/custom_distri.yaml
|
||||
|
||||
.. _project:
|
||||
|
||||
Project
|
||||
|
@ -79,7 +79,11 @@ def deep_format(obj, paramdict):
|
||||
# example, is problematic).
|
||||
if isinstance(obj, str):
|
||||
try:
|
||||
ret = obj.format(**paramdict)
|
||||
result = re.match('^{obj:(?P<key>\w+)}$', obj)
|
||||
if result is not None:
|
||||
ret = paramdict[result.group("key")]
|
||||
else:
|
||||
ret = obj.format(**paramdict)
|
||||
except KeyError as exc:
|
||||
missing_key = exc.message
|
||||
desc = "%s parameter missing to format %s\nGiven: %s" % (
|
||||
|
35
tests/yamlparser/fixtures/custom_distri.xml
Normal file
35
tests/yamlparser/fixtures/custom_distri.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<matrix-project>
|
||||
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
|
||||
<runSequentially>false</runSequentially>
|
||||
</executionStrategy>
|
||||
<combinationFilter/>
|
||||
<axes>
|
||||
<hudson.matrix.TextAxis>
|
||||
<name>distribution</name>
|
||||
<values>
|
||||
<string>precise</string>
|
||||
<string>jessie</string>
|
||||
</values>
|
||||
</hudson.matrix.TextAxis>
|
||||
<hudson.matrix.TextAxis>
|
||||
<name>architectures</name>
|
||||
<values>
|
||||
<string>amd64</string>
|
||||
<string>i386</string>
|
||||
</values>
|
||||
</hudson.matrix.TextAxis>
|
||||
</axes>
|
||||
<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/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</matrix-project>
|
22
tests/yamlparser/fixtures/custom_distri.yaml
Normal file
22
tests/yamlparser/fixtures/custom_distri.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
- project:
|
||||
name: test_custom_distri
|
||||
distributions: !!python/tuple [precise, jessie]
|
||||
architectures: !!python/tuple &architectures
|
||||
- amd64
|
||||
- i386
|
||||
axis_a:
|
||||
type: user-defined
|
||||
name: architectures
|
||||
values: *architectures
|
||||
jobs:
|
||||
- '{name}-source'
|
||||
|
||||
- job-template:
|
||||
name: '{name}-source'
|
||||
project-type: matrix
|
||||
axes:
|
||||
- axis:
|
||||
type: user-defined
|
||||
name: distribution
|
||||
values: '{obj:distributions}'
|
||||
- axis: '{obj:axis_a}'
|
Loading…
x
Reference in New Issue
Block a user