Handle nested brace inside variable

Change-Id: I1004ea869bfe56b380109c7bcae866931b4d4725
This commit is contained in:
Vsevolod Fedorov 2023-11-15 11:25:59 +03:00
parent 21f0506e65
commit 1a65a1d44b
3 changed files with 23 additions and 1 deletions

View File

@ -77,7 +77,7 @@ class CustomFormatter(Formatter):
try:
return super().vformat(format_string, args, kwargs)
except (JenkinsJobsException, UndefinedError) as x:
except (JenkinsJobsException, UndefinedError, ValueError) as x:
if len(format_string) > 40:
short_fmt = format_string[:80] + "..."
else:

View File

@ -0,0 +1,9 @@
nested_brace_in_variable.yaml:10:3: In project 'sample-project'
- project:
^
nested_brace_in_variable.yaml:5:3: In job template 'sample-job'
- job-template:
^
nested_brace_in_variable.yaml:8:15: While formatting string '{ {x} }': unexpected '{' in field name
- shell: '{ {x} }'
^

View File

@ -0,0 +1,13 @@
# Check braces inside variable does not cause parser to fail.
# This may happen when tag !include-raw: is used instead of !include-raw-escape:
# and there are nested blocks of groovy code inside included file.
- job-template:
name: sample-job
builders:
- shell: '{ {x} }'
- project:
name: sample-project
jobs:
- sample-job