Merge "Preserve template-name via escaping"
This commit is contained in:
commit
20afabf4b8
@ -33,9 +33,7 @@ def deep_format(obj, paramdict, allow_empty=False):
|
||||
# limitations on the values in paramdict - the post-format result must
|
||||
# still be valid YAML (so substituting-in a string containing quotes, for
|
||||
# example, is problematic).
|
||||
if getattr(obj, 'verbatim', False) is True:
|
||||
ret = obj
|
||||
elif hasattr(obj, 'format'):
|
||||
if hasattr(obj, 'format'):
|
||||
try:
|
||||
ret = CustomFormatter(allow_empty).format(obj, **paramdict)
|
||||
except KeyError as exc:
|
||||
@ -137,10 +135,3 @@ class CustomFormatter(Formatter):
|
||||
)
|
||||
return ''
|
||||
raise
|
||||
|
||||
|
||||
class VerbatimString(str):
|
||||
"""
|
||||
String which is not expanded by `deep_format`.
|
||||
"""
|
||||
verbatim = True
|
||||
|
@ -20,11 +20,12 @@ import fnmatch
|
||||
import io
|
||||
import itertools
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
|
||||
from jenkins_jobs.constants import MAGIC_MANAGE_STRING
|
||||
from jenkins_jobs.errors import JenkinsJobsException
|
||||
from jenkins_jobs.formatter import deep_format, VerbatimString
|
||||
from jenkins_jobs.formatter import deep_format
|
||||
import jenkins_jobs.local_yaml as local_yaml
|
||||
from jenkins_jobs import utils
|
||||
|
||||
@ -346,8 +347,8 @@ class YamlParser(object):
|
||||
|
||||
for values in itertools.product(*dimensions):
|
||||
params = copy.deepcopy(project)
|
||||
params['template-name'] = VerbatimString(template_name)
|
||||
params = self._applyDefaults(params, template)
|
||||
params['template-name'] = re.sub(r'({|})', r'\1\1', template_name)
|
||||
|
||||
try:
|
||||
expanded_values = {}
|
||||
|
Loading…
Reference in New Issue
Block a user