Revert "Allow using template variables in "defaults" field."
This reverts commit 70ed22362a9c13ea9f3165e5747dcca281ad439c. I knew I should have tested the patch with my own templates. Doing so I discovered a nasty regression: The defaults can make use of variables passed by the project. By moving applyDEfaults to be called after deep_format is performed on job templates, any substitutioncontained withing defaults is no longer correctly replaced by project parameters. Change-Id: I69ffb3e28093af6db62962786d9275bf3ba4e115
This commit is contained in:
parent
442d5c8a2c
commit
ab434cc288
@ -298,11 +298,6 @@ definitions unless they specify a different Default object with the
|
|||||||
|
|
||||||
Will set the job description for every job created.
|
Will set the job description for every job created.
|
||||||
|
|
||||||
Template variables can also be used to specify an appropriate set of
|
|
||||||
defaults for each generated job:
|
|
||||||
|
|
||||||
.. literalinclude:: /../../tests/yamlparser/fixtures/templates003.yaml
|
|
||||||
|
|
||||||
.. _advanced:
|
.. _advanced:
|
||||||
|
|
||||||
Advanced
|
Advanced
|
||||||
|
@ -172,7 +172,10 @@ class YamlParser(object):
|
|||||||
return self.data.get('job-group', {}).get(name, None)
|
return self.data.get('job-group', {}).get(name, None)
|
||||||
|
|
||||||
def getJobTemplate(self, name):
|
def getJobTemplate(self, name):
|
||||||
return self.data.get('job-template', {}).get(name, None)
|
job = self.data.get('job-template', {}).get(name, None)
|
||||||
|
if not job:
|
||||||
|
return job
|
||||||
|
return self.applyDefaults(job)
|
||||||
|
|
||||||
def applyDefaults(self, data):
|
def applyDefaults(self, data):
|
||||||
whichdefaults = data.get('defaults', 'global')
|
whichdefaults = data.get('defaults', 'global')
|
||||||
@ -278,7 +281,7 @@ class YamlParser(object):
|
|||||||
expanded_values[k] = v
|
expanded_values[k] = v
|
||||||
|
|
||||||
params.update(expanded_values)
|
params.update(expanded_values)
|
||||||
expanded = self.applyDefaults(deep_format(template, params))
|
expanded = deep_format(template, params)
|
||||||
|
|
||||||
# Keep track of the resulting expansions to avoid
|
# Keep track of the resulting expansions to avoid
|
||||||
# regenerating the exact same job. Whenever a project has
|
# regenerating the exact same job. Whenever a project has
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<project>
|
|
||||||
<actions/>
|
|
||||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
|
||||||
<keepDependencies>false</keepDependencies>
|
|
||||||
<disabled>false</disabled>
|
|
||||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
|
||||||
<blockBuildWhenUpstreamBuilding>true</blockBuildWhenUpstreamBuilding>
|
|
||||||
<concurrentBuild>false</concurrentBuild>
|
|
||||||
<canRoam>true</canRoam>
|
|
||||||
<properties/>
|
|
||||||
<scm class="hudson.scm.NullSCM"/>
|
|
||||||
<builders/>
|
|
||||||
<publishers/>
|
|
||||||
<buildWrappers>
|
|
||||||
<hudson.plugins.timestamper.TimestamperBuildWrapper/>
|
|
||||||
<hudson.plugins.ws__cleanup.PreBuildCleanup plugin="ws-cleanup@0.14">
|
|
||||||
<deleteDirs>false</deleteDirs>
|
|
||||||
</hudson.plugins.ws__cleanup.PreBuildCleanup>
|
|
||||||
</buildWrappers>
|
|
||||||
</project>
|
|
||||||
<BLANKLINE>
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<project>
|
|
||||||
<actions/>
|
|
||||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
|
||||||
<keepDependencies>false</keepDependencies>
|
|
||||||
<disabled>false</disabled>
|
|
||||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
|
||||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
|
||||||
<concurrentBuild>false</concurrentBuild>
|
|
||||||
<canRoam>true</canRoam>
|
|
||||||
<properties/>
|
|
||||||
<scm class="hudson.scm.NullSCM"/>
|
|
||||||
<builders/>
|
|
||||||
<publishers/>
|
|
||||||
<buildWrappers>
|
|
||||||
<hudson.plugins.timestamper.TimestamperBuildWrapper/>
|
|
||||||
</buildWrappers>
|
|
||||||
</project>
|
|
@ -1,29 +0,0 @@
|
|||||||
- defaults:
|
|
||||||
name: Foo
|
|
||||||
disabled: false
|
|
||||||
block-downstream: false
|
|
||||||
block-upstream: false
|
|
||||||
wrappers:
|
|
||||||
- timestamps
|
|
||||||
|
|
||||||
- defaults:
|
|
||||||
name: Bar
|
|
||||||
disabled: false
|
|
||||||
block-downstream: false
|
|
||||||
block-upstream: true
|
|
||||||
wrappers:
|
|
||||||
- timestamps
|
|
||||||
- workspace-cleanup
|
|
||||||
|
|
||||||
- job-template:
|
|
||||||
name: '{component}-Test'
|
|
||||||
project-type: freestyle
|
|
||||||
defaults: '{component}'
|
|
||||||
|
|
||||||
- project:
|
|
||||||
name: Test-project
|
|
||||||
component:
|
|
||||||
- Foo
|
|
||||||
- Bar
|
|
||||||
jobs:
|
|
||||||
- '{component}-Test'
|
|
Loading…
x
Reference in New Issue
Block a user