Add template-name as a variable that can be used in a template

In complex configurations it may be useful to have a template
print out its name so that a given job can be easily traced to
its definition.

Change-Id: I1cfed9c27a58b45ba48aeed04839bfc8f54a831e
This commit is contained in:
James E. Blair 2015-11-18 17:11:21 -08:00
parent 294dea66b2
commit 7ef05f7373
3 changed files with 5 additions and 0 deletions

View File

@ -294,6 +294,7 @@ class YamlParser(object):
if key not in params:
params[key] = template[key]
params['template-name'] = template_name
expanded = deep_format(template, params, allow_empty_variables)
job_name = expanded.get('name')

View File

@ -104,6 +104,9 @@
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
<builders>
<hudson.tasks.Shell>
<command>echo JJB template: complete001_{version}</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>#!/usr/bin/env python
#

View File

@ -99,6 +99,7 @@
- pre-scm-shell-ant
- copy-files
builders:
- shell: 'echo JJB template: {template-name}'
- shell: |
#!/usr/bin/env python
#