diff --git a/jenkins_jobs/formatter.py b/jenkins_jobs/formatter.py index 7eaab5980..008d66e74 100644 --- a/jenkins_jobs/formatter.py +++ b/jenkins_jobs/formatter.py @@ -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: @@ -131,10 +129,3 @@ class CustomFormatter(Formatter): ) return '' raise - - -class VerbatimString(str): - """ - String which is not expanded by `deep_format`. - """ - verbatim = True diff --git a/jenkins_jobs/parser.py b/jenkins_jobs/parser.py index b3b9bcffc..656af17b9 100644 --- a/jenkins_jobs/parser.py +++ b/jenkins_jobs/parser.py @@ -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 = {}