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