From 36b9d8bfcade3569cf6e23e689a19d44c001d3f9 Mon Sep 17 00:00:00 2001 From: Vsevolod Fedorov Date: Tue, 6 Feb 2024 11:49:10 +0300 Subject: [PATCH] Add tags: '!include-raw-verbatim:' and '!include-raw-expand:' Use '!include-raw-expand:' instead of '!include-raw:' and '!include-raw-verbatim:' instead of '!include-raw-escape:'. Tags '!include-raw:' and '!include-raw-escape:' are now deprecated. Change-Id: I3cc5ab9f73d03de1ba09cbc4568366a3bb464a08 --- jenkins_jobs/expander.py | 14 +++--- jenkins_jobs/yaml_objects.py | 28 ++++++------ .../include-raw-escaped-multi001.json | 11 ----- .../fixtures/include-raw-escaped001-job.json | 14 ------ .../fixtures/include-raw-escaped001-job.yaml | 8 ---- .../include-raw-escaped001-template.json | 14 ------ .../fixtures/include-raw-expand-template.json | 11 +++++ ...te.xml => include-raw-expand-template.xml} | 4 +- ....yaml => include-raw-expand-template.yaml} | 2 +- .../fixtures/include-raw-hello-world.sh | 9 ++++ .../loader/fixtures/include-raw-multi001.json | 11 ----- .../loader/fixtures/include-raw-multi001.yaml | 7 --- .../fixtures/include-raw-parameterized.sh | 14 ++++++ tests/loader/fixtures/include-raw-vars.sh | 14 ++++++ .../fixtures/include-raw-verbatim-job.json | 14 ++++++ ...plate.xml => include-raw-verbatim-job.xml} | 6 +-- .../fixtures/include-raw-verbatim-job.yaml | 8 ++++ .../include-raw-verbatim-multi-job.json | 11 +++++ ...xml => include-raw-verbatim-multi-job.xml} | 6 +-- .../include-raw-verbatim-multi-job.yaml | 7 +++ .../include-raw-verbatim-multi-template.json | 11 +++++ ...> include-raw-verbatim-multi-template.xml} | 6 +-- ... include-raw-verbatim-multi-template.yaml} | 6 +-- .../include-raw-verbatim-template.json | 14 ++++++ .../include-raw-verbatim-template.xml | 45 +++++++++++++++++++ .../include-raw-verbatim-template.yaml | 13 ++++++ tests/loader/fixtures/include-raw001-job.json | 14 ------ tests/loader/fixtures/include-raw001-job.yaml | 7 --- .../fixtures/include-raw001-template.json | 11 ----- .../include_raw_escape_missing_path.error | 9 ---- .../include_raw_expand_missing_path.error | 9 ++++ ...l => include_raw_expand_missing_path.yaml} | 2 +- .../include_raw_missing_path.error | 9 ---- .../include_raw_verbatim_missing_path.error | 9 ++++ ...=> include_raw_verbatim_missing_path.yaml} | 2 +- .../missing_param_in_include_raw.error | 10 ----- .../missing_param_in_include_raw_expand.error | 10 +++++ ...> missing_param_in_include_raw_expand.inc} | 0 ... missing_param_in_include_raw_expand.yaml} | 2 +- .../nested_brace_in_variable.yaml | 2 +- ...ated-include-raw-escaped002.hello-world.sh | 9 ++++ ...deprecated-include-raw-escaped002.vars.sh} | 4 +- .../deprecated-include-raw-escaped002.xml} | 6 +-- .../deprecated-include-raw-escaped002.yaml} | 4 +- .../deprecated-include-raw002.hello-world.sh} | 0 .../deprecated-include-raw002.vars.sh} | 4 +- .../deprecated-include-raw002.xml} | 2 +- .../deprecated-include-raw002.yaml | 7 +++ .../job_fixtures/include-raw-expand-cool.sh | 2 + ...2-cool.zsh => include-raw-expand-cool.zsh} | 0 ....sh => include-raw-expand-unicode-cool.sh} | 0 ...001.xml => include-raw-expand-unicode.xml} | 0 ...1.yaml => include-raw-expand-unicode.yaml} | 2 +- ...lude-raw001.xml => include-raw-expand.xml} | 0 ...de-raw001.yaml => include-raw-expand.yaml} | 4 +- ...s.sh => include-raw-verbatim-echo-vars.sh} | 2 +- ...cape001.conf => include-raw-verbatim.conf} | 0 ...escape001.xml => include-raw-verbatim.xml} | 2 +- ...cape001.yaml => include-raw-verbatim.yaml} | 2 +- .../yamlparser/job_fixtures/jinja-yaml03.yaml | 4 +- .../job-and-macro-expansions.yaml | 12 ++--- .../job_fixtures/lazy-load-jobs-multi001.yaml | 2 +- .../job_fixtures/lazy-load-jobs-multi002.yaml | 2 +- .../job_fixtures/lazy-load-jobs001.yaml | 2 +- .../job_fixtures/lazy-load-jobs002.yaml | 2 +- .../lazy-load-with-variables.yaml | 2 +- .../job_fixtures/regression-2006254.yaml | 2 +- .../job_fixtures/regression-2007227.yaml | 4 +- .../regression-2010711/job_1/job_1.yaml | 2 +- .../regression-2010711/job_2/job_2.yaml | 2 +- ...g_in_parameter-include-raw-expand.inc.txt} | 0 ...> tag_in_parameter-include-raw-expand.xml} | 0 ... tag_in_parameter-include-raw-expand.yaml} | 4 +- ...in_parameter-include-raw-verbatim.inc.txt} | 0 ...tag_in_parameter-include-raw-verbatim.xml} | 0 ...ag_in_parameter-include-raw-verbatim.yaml} | 4 +- 76 files changed, 296 insertions(+), 202 deletions(-) delete mode 100644 tests/loader/fixtures/include-raw-escaped-multi001.json delete mode 100644 tests/loader/fixtures/include-raw-escaped001-job.json delete mode 100644 tests/loader/fixtures/include-raw-escaped001-job.yaml delete mode 100644 tests/loader/fixtures/include-raw-escaped001-template.json create mode 100644 tests/loader/fixtures/include-raw-expand-template.json rename tests/loader/fixtures/{include-raw001-template.xml => include-raw-expand-template.xml} (87%) rename tests/loader/fixtures/{include-raw001-template.yaml => include-raw-expand-template.yaml} (75%) create mode 100644 tests/loader/fixtures/include-raw-hello-world.sh delete mode 100644 tests/loader/fixtures/include-raw-multi001.json delete mode 100644 tests/loader/fixtures/include-raw-multi001.yaml create mode 100644 tests/loader/fixtures/include-raw-parameterized.sh create mode 100644 tests/loader/fixtures/include-raw-vars.sh create mode 100644 tests/loader/fixtures/include-raw-verbatim-job.json rename tests/loader/fixtures/{include-raw-escaped001-template.xml => include-raw-verbatim-job.xml} (84%) create mode 100644 tests/loader/fixtures/include-raw-verbatim-job.yaml create mode 100644 tests/loader/fixtures/include-raw-verbatim-multi-job.json rename tests/loader/fixtures/{include-raw-escaped-multi001.xml => include-raw-verbatim-multi-job.xml} (83%) create mode 100644 tests/loader/fixtures/include-raw-verbatim-multi-job.yaml create mode 100644 tests/loader/fixtures/include-raw-verbatim-multi-template.json rename tests/loader/fixtures/{include-raw-multi001.xml => include-raw-verbatim-multi-template.xml} (83%) rename tests/loader/fixtures/{include-raw-escaped-multi001.yaml => include-raw-verbatim-multi-template.yaml} (61%) create mode 100644 tests/loader/fixtures/include-raw-verbatim-template.json create mode 100644 tests/loader/fixtures/include-raw-verbatim-template.xml create mode 100644 tests/loader/fixtures/include-raw-verbatim-template.yaml delete mode 100644 tests/loader/fixtures/include-raw001-job.json delete mode 100644 tests/loader/fixtures/include-raw001-job.yaml delete mode 100644 tests/loader/fixtures/include-raw001-template.json delete mode 100644 tests/yamlparser/error_fixtures/include_raw_escape_missing_path.error create mode 100644 tests/yamlparser/error_fixtures/include_raw_expand_missing_path.error rename tests/yamlparser/error_fixtures/{include_raw_missing_path.yaml => include_raw_expand_missing_path.yaml} (73%) delete mode 100644 tests/yamlparser/error_fixtures/include_raw_missing_path.error create mode 100644 tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.error rename tests/yamlparser/error_fixtures/{include_raw_escape_missing_path.yaml => include_raw_verbatim_missing_path.yaml} (72%) delete mode 100644 tests/yamlparser/error_fixtures/missing_param_in_include_raw.error create mode 100644 tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.error rename tests/yamlparser/error_fixtures/{missing_param_in_include_raw.inc => missing_param_in_include_raw_expand.inc} (100%) rename tests/yamlparser/error_fixtures/{missing_param_in_include_raw.yaml => missing_param_in_include_raw_expand.yaml} (60%) create mode 100644 tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.hello-world.sh rename tests/{loader/fixtures/include-raw001-vars.sh => yamlparser/job_fixtures/deprecated-include-raw-escaped002.vars.sh} (59%) rename tests/{loader/fixtures/include-raw001-job.xml => yamlparser/job_fixtures/deprecated-include-raw-escaped002.xml} (85%) rename tests/{loader/fixtures/include-raw-escaped001-template.yaml => yamlparser/job_fixtures/deprecated-include-raw-escaped002.yaml} (56%) rename tests/{loader/fixtures/include-raw001-hello-world.sh => yamlparser/job_fixtures/deprecated-include-raw002.hello-world.sh} (100%) rename tests/{loader/fixtures/include-raw001-parameterized.sh => yamlparser/job_fixtures/deprecated-include-raw002.vars.sh} (75%) rename tests/{loader/fixtures/include-raw-escaped001-job.xml => yamlparser/job_fixtures/deprecated-include-raw002.xml} (95%) create mode 100644 tests/yamlparser/job_fixtures/deprecated-include-raw002.yaml create mode 100644 tests/yamlparser/job_fixtures/include-raw-expand-cool.sh rename tests/yamlparser/job_fixtures/{include-raw002-cool.zsh => include-raw-expand-cool.zsh} (100%) rename tests/yamlparser/job_fixtures/{include-rawunicode001-cool.sh => include-raw-expand-unicode-cool.sh} (100%) rename tests/yamlparser/job_fixtures/{include-rawunicode001.xml => include-raw-expand-unicode.xml} (100%) rename tests/yamlparser/job_fixtures/{include-rawunicode001.yaml => include-raw-expand-unicode.yaml} (76%) rename tests/yamlparser/job_fixtures/{include-raw001.xml => include-raw-expand.xml} (100%) rename tests/yamlparser/job_fixtures/{include-raw001.yaml => include-raw-expand.yaml} (88%) rename tests/yamlparser/job_fixtures/{include-raw-escape001-echo-vars.sh => include-raw-verbatim-echo-vars.sh} (72%) rename tests/yamlparser/job_fixtures/{include-raw-escape001.conf => include-raw-verbatim.conf} (100%) rename tests/yamlparser/job_fixtures/{include-raw-escape001.xml => include-raw-verbatim.xml} (94%) rename tests/yamlparser/job_fixtures/{include-raw-escape001.yaml => include-raw-verbatim.yaml} (84%) rename tests/yamlparser/job_fixtures/{tag_in_parameter-include-raw-escape.inc.txt => tag_in_parameter-include-raw-expand.inc.txt} (100%) rename tests/yamlparser/job_fixtures/{tag_in_parameter-include-raw-escape.xml => tag_in_parameter-include-raw-expand.xml} (100%) rename tests/yamlparser/job_fixtures/{tag_in_parameter-include-raw-escape.yaml => tag_in_parameter-include-raw-expand.yaml} (57%) rename tests/yamlparser/job_fixtures/{tag_in_parameter-include-raw.inc.txt => tag_in_parameter-include-raw-verbatim.inc.txt} (100%) rename tests/yamlparser/job_fixtures/{tag_in_parameter-include-raw.xml => tag_in_parameter-include-raw-verbatim.xml} (100%) rename tests/yamlparser/job_fixtures/{tag_in_parameter-include-raw.yaml => tag_in_parameter-include-raw-verbatim.yaml} (56%) diff --git a/jenkins_jobs/expander.py b/jenkins_jobs/expander.py index a0143591e..57ded06f8 100644 --- a/jenkins_jobs/expander.py +++ b/jenkins_jobs/expander.py @@ -23,8 +23,8 @@ from .yaml_objects import ( YamlInclude, YamlListJoin, IncludeJinja2, - IncludeRaw, - IncludeRawEscape, + IncludeRawExpand, + IncludeRawVerbatim, ) @@ -92,14 +92,16 @@ yaml_classes_list = [ YamlInclude, YamlListJoin, IncludeJinja2, - IncludeRaw, - IncludeRawEscape, + IncludeRawExpand, + IncludeRawVerbatim, ] deprecated_yaml_tags = [ ("!include", YamlInclude), - ("!include-raw", IncludeRaw), - ("!include-raw-escape", IncludeRawEscape), + ("!include-raw", IncludeRawExpand), + ("!include-raw:", IncludeRawExpand), + ("!include-raw-escape", IncludeRawVerbatim), + ("!include-raw-escape:", IncludeRawVerbatim), ] diff --git a/jenkins_jobs/yaml_objects.py b/jenkins_jobs/yaml_objects.py index a9134d6ea..e0b52fae3 100644 --- a/jenkins_jobs/yaml_objects.py +++ b/jenkins_jobs/yaml_objects.py @@ -78,34 +78,34 @@ Example: .. literalinclude:: /../../tests/loader/fixtures/include001.yaml.inc -The tag ``!include-raw:`` will treat the given string or list of strings as -filenames to be opened as one or more data blob, which should be read into +The tag ``!include-raw-expand:`` will treat the given string or list of strings +as filenames to be opened as one or more data blob, which should be read into the calling yaml construct without any further parsing. Any data in a file included through this tag, will be treated as string data. It will expand variables inside the file. If your file contains curly braces, -you should double them. Or, you can use tag ``!include-raw-escape``, which +you should double them. Or, you can use tag ``!include-raw-verbatim:``, which does not substitute variables. Examples: .. literalinclude:: - /../../tests/loader/fixtures/include-raw-escaped001-template.yaml + /../../tests/loader/fixtures/include-raw-verbatim-template.yaml - contents of include-raw001-hello-world.sh: + contents of include-raw-hello-world.sh: .. literalinclude:: - /../../tests/loader/fixtures/include-raw001-hello-world.sh + /../../tests/loader/fixtures/include-raw-hello-world.sh - contents of include-raw001-vars.sh: + contents of include-raw-vars.sh: .. literalinclude:: - /../../tests/loader/fixtures/include-raw001-vars.sh + /../../tests/loader/fixtures/include-raw-vars.sh - using a list of files: + Using a list of files: .. literalinclude:: - /../../tests/loader/fixtures/include-raw-escaped-multi001.yaml + /../../tests/loader/fixtures/include-raw-verbatim-multi-template.yaml For all the multi file includes, the files are simply appended using a newline @@ -400,8 +400,8 @@ class IncludeRawBase(IncludeBaseObject): return "\n".join(self._expand_path_list(self._path_list, params)) -class IncludeRaw(IncludeRawBase): - yaml_tag = "!include-raw:" +class IncludeRawExpand(IncludeRawBase): + yaml_tag = "!include-raw-expand:" def _expand_path(self, rel_path_template, pos, params): rel_path = self._formatter.format(rel_path_template, **params) @@ -413,8 +413,8 @@ class IncludeRaw(IncludeRawBase): raise x.with_context(f"In included file {str(full_path)!r}", pos=self._pos) -class IncludeRawEscape(IncludeRawBase): - yaml_tag = "!include-raw-escape:" +class IncludeRawVerbatim(IncludeRawBase): + yaml_tag = "!include-raw-verbatim:" def _expand_path(self, rel_path_template, pos, params): rel_path = self._formatter.format(rel_path_template, **params) diff --git a/tests/loader/fixtures/include-raw-escaped-multi001.json b/tests/loader/fixtures/include-raw-escaped-multi001.json deleted file mode 100644 index b6ba734e7..000000000 --- a/tests/loader/fixtures/include-raw-escaped-multi001.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "builders": [ - { - "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml include-raw tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n\n#!/bin/bash\n#\n# sample script to check that brackets aren't escaped\n# when using the include-raw application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" - } - ], - "description": "", - "name": "test-job-include-raw-1" - } -] diff --git a/tests/loader/fixtures/include-raw-escaped001-job.json b/tests/loader/fixtures/include-raw-escaped001-job.json deleted file mode 100644 index 6a210d138..000000000 --- a/tests/loader/fixtures/include-raw-escaped001-job.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "builders": [ - { - "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml include-raw tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n" - }, - { - "shell": "#!/bin/bash\n#\n# sample script to check that brackets aren't escaped\n# when using the include-raw application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" - } - ], - "description": "", - "name": "test-job-include-raw" - } -] diff --git a/tests/loader/fixtures/include-raw-escaped001-job.yaml b/tests/loader/fixtures/include-raw-escaped001-job.yaml deleted file mode 100644 index 4cfcc9c7d..000000000 --- a/tests/loader/fixtures/include-raw-escaped001-job.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Using include-raw-escape inside job works the same way as inside job template. -- job: - name: test-job-include-raw - builders: - - shell: - !include-raw-escape: include-raw001-hello-world.sh - - shell: - !include-raw-escape: include-raw001-vars.sh diff --git a/tests/loader/fixtures/include-raw-escaped001-template.json b/tests/loader/fixtures/include-raw-escaped001-template.json deleted file mode 100644 index 8ec298fde..000000000 --- a/tests/loader/fixtures/include-raw-escaped001-template.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "builders": [ - { - "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml include-raw tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n" - }, - { - "shell": "#!/bin/bash\n#\n# sample script to check that brackets aren't escaped\n# when using the include-raw application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" - } - ], - "description": "", - "name": "test-job-include-raw-1" - } -] diff --git a/tests/loader/fixtures/include-raw-expand-template.json b/tests/loader/fixtures/include-raw-expand-template.json new file mode 100644 index 000000000..45da55374 --- /dev/null +++ b/tests/loader/fixtures/include-raw-expand-template.json @@ -0,0 +1,11 @@ +[ + { + "builders": [ + { + "shell": "#!/bin/bash\n#\n# sample script to check that variables are expanded\n# when using the !include-raw-expand: application yaml tag\n\nVAR1=\"1\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" + } + ], + "description": "", + "name": "test-job-include-raw-1" + } +] diff --git a/tests/loader/fixtures/include-raw001-template.xml b/tests/loader/fixtures/include-raw-expand-template.xml similarity index 87% rename from tests/loader/fixtures/include-raw001-template.xml rename to tests/loader/fixtures/include-raw-expand-template.xml index 372806b6b..4249b3e50 100644 --- a/tests/loader/fixtures/include-raw001-template.xml +++ b/tests/loader/fixtures/include-raw-expand-template.xml @@ -13,8 +13,8 @@ #!/bin/bash # -# sample script to check that brackets aren't escaped -# when using the include-raw application yaml tag +# sample script to check that variables are expanded +# when using the !include-raw-expand: application yaml tag VAR1="1" VAR2="world" diff --git a/tests/loader/fixtures/include-raw001-template.yaml b/tests/loader/fixtures/include-raw-expand-template.yaml similarity index 75% rename from tests/loader/fixtures/include-raw001-template.yaml rename to tests/loader/fixtures/include-raw-expand-template.yaml index 3413433e4..51e9a8ec7 100644 --- a/tests/loader/fixtures/include-raw001-template.yaml +++ b/tests/loader/fixtures/include-raw-expand-template.yaml @@ -2,7 +2,7 @@ name: test-job-include-raw-{num} builders: - shell: - !include-raw: include-raw001-parameterized.sh + !include-raw-expand: include-raw-parameterized.sh - project: name: test-job-template diff --git a/tests/loader/fixtures/include-raw-hello-world.sh b/tests/loader/fixtures/include-raw-hello-world.sh new file mode 100644 index 000000000..758420c7a --- /dev/null +++ b/tests/loader/fixtures/include-raw-hello-world.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Sample script showing how the yaml !include-raw-verbatim: tag can be used +# to inline scripts that are maintained outside of the jenkins +# job yaml configuration. + +echo "hello world" + +exit 0 diff --git a/tests/loader/fixtures/include-raw-multi001.json b/tests/loader/fixtures/include-raw-multi001.json deleted file mode 100644 index b6ba734e7..000000000 --- a/tests/loader/fixtures/include-raw-multi001.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "builders": [ - { - "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml include-raw tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n\n#!/bin/bash\n#\n# sample script to check that brackets aren't escaped\n# when using the include-raw application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" - } - ], - "description": "", - "name": "test-job-include-raw-1" - } -] diff --git a/tests/loader/fixtures/include-raw-multi001.yaml b/tests/loader/fixtures/include-raw-multi001.yaml deleted file mode 100644 index bf0927c57..000000000 --- a/tests/loader/fixtures/include-raw-multi001.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- job: - name: test-job-include-raw-1 - builders: - - shell: - !include-raw-escape: - - include-raw001-hello-world.sh - - include-raw001-vars.sh diff --git a/tests/loader/fixtures/include-raw-parameterized.sh b/tests/loader/fixtures/include-raw-parameterized.sh new file mode 100644 index 000000000..fdd3371dc --- /dev/null +++ b/tests/loader/fixtures/include-raw-parameterized.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# sample script to check that variables are expanded +# when using the !include-raw-expand: application yaml tag + +VAR1="{num}" +VAR2="world" +VAR3="${{VAR1}} ${{VAR2}}" + +[[ -n "${{VAR3}}" ]] && {{ + # this next section is executed as one + echo "${{VAR3}}" + exit 0 +}} diff --git a/tests/loader/fixtures/include-raw-vars.sh b/tests/loader/fixtures/include-raw-vars.sh new file mode 100644 index 000000000..7cedeaed4 --- /dev/null +++ b/tests/loader/fixtures/include-raw-vars.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# sample script to check that variables aren't expanded +# when using the !include-raw-verbatim: application yaml tag + +VAR1="hello" +VAR2="world" +VAR3="${VAR1} ${VAR2}" + +[[ -n "${VAR3}" ]] && { + # this next section is executed as one + echo "${VAR3}" + exit 0 +} diff --git a/tests/loader/fixtures/include-raw-verbatim-job.json b/tests/loader/fixtures/include-raw-verbatim-job.json new file mode 100644 index 000000000..a11f74837 --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-job.json @@ -0,0 +1,14 @@ +[ + { + "builders": [ + { + "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml !include-raw-verbatim: tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n" + }, + { + "shell": "#!/bin/bash\n#\n# sample script to check that variables aren't expanded\n# when using the !include-raw-verbatim: application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" + } + ], + "description": "", + "name": "test-include-raw-verbatim-job" + } +] diff --git a/tests/loader/fixtures/include-raw-escaped001-template.xml b/tests/loader/fixtures/include-raw-verbatim-job.xml similarity index 84% rename from tests/loader/fixtures/include-raw-escaped001-template.xml rename to tests/loader/fixtures/include-raw-verbatim-job.xml index 9a48dc3d9..f164110ec 100644 --- a/tests/loader/fixtures/include-raw-escaped001-template.xml +++ b/tests/loader/fixtures/include-raw-verbatim-job.xml @@ -13,7 +13,7 @@ #!/bin/bash # -# Sample script showing how the yaml include-raw tag can be used +# Sample script showing how the yaml !include-raw-verbatim: tag can be used # to inline scripts that are maintained outside of the jenkins # job yaml configuration. @@ -25,8 +25,8 @@ exit 0 #!/bin/bash # -# sample script to check that brackets aren't escaped -# when using the include-raw application yaml tag +# sample script to check that variables aren't expanded +# when using the !include-raw-verbatim: application yaml tag VAR1="hello" VAR2="world" diff --git a/tests/loader/fixtures/include-raw-verbatim-job.yaml b/tests/loader/fixtures/include-raw-verbatim-job.yaml new file mode 100644 index 000000000..247e8f365 --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-job.yaml @@ -0,0 +1,8 @@ +# Using !include-raw-verbatim: inside job works the same way as inside job template. +- job: + name: test-include-raw-verbatim-job + builders: + - shell: + !include-raw-verbatim: include-raw-hello-world.sh + - shell: + !include-raw-verbatim: include-raw-vars.sh diff --git a/tests/loader/fixtures/include-raw-verbatim-multi-job.json b/tests/loader/fixtures/include-raw-verbatim-multi-job.json new file mode 100644 index 000000000..428ff1408 --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-multi-job.json @@ -0,0 +1,11 @@ +[ + { + "builders": [ + { + "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml !include-raw-verbatim: tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n\n#!/bin/bash\n#\n# sample script to check that variables aren't expanded\n# when using the !include-raw-verbatim: application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" + } + ], + "description": "", + "name": "test-job-include-raw-verbatim-multi-001" + } +] diff --git a/tests/loader/fixtures/include-raw-escaped-multi001.xml b/tests/loader/fixtures/include-raw-verbatim-multi-job.xml similarity index 83% rename from tests/loader/fixtures/include-raw-escaped-multi001.xml rename to tests/loader/fixtures/include-raw-verbatim-multi-job.xml index 5af950716..ba62d0292 100644 --- a/tests/loader/fixtures/include-raw-escaped-multi001.xml +++ b/tests/loader/fixtures/include-raw-verbatim-multi-job.xml @@ -13,7 +13,7 @@ #!/bin/bash # -# Sample script showing how the yaml include-raw tag can be used +# Sample script showing how the yaml !include-raw-verbatim: tag can be used # to inline scripts that are maintained outside of the jenkins # job yaml configuration. @@ -23,8 +23,8 @@ exit 0 #!/bin/bash # -# sample script to check that brackets aren't escaped -# when using the include-raw application yaml tag +# sample script to check that variables aren't expanded +# when using the !include-raw-verbatim: application yaml tag VAR1="hello" VAR2="world" diff --git a/tests/loader/fixtures/include-raw-verbatim-multi-job.yaml b/tests/loader/fixtures/include-raw-verbatim-multi-job.yaml new file mode 100644 index 000000000..ff90456fa --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-multi-job.yaml @@ -0,0 +1,7 @@ +- job: + name: test-job-include-raw-verbatim-multi-001 + builders: + - shell: + !include-raw-verbatim: + - include-raw-hello-world.sh + - include-raw-vars.sh diff --git a/tests/loader/fixtures/include-raw-verbatim-multi-template.json b/tests/loader/fixtures/include-raw-verbatim-multi-template.json new file mode 100644 index 000000000..67dbe256e --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-multi-template.json @@ -0,0 +1,11 @@ +[ + { + "builders": [ + { + "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml !include-raw-verbatim: tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n\n#!/bin/bash\n#\n# sample script to check that variables aren't expanded\n# when using the !include-raw-verbatim: application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" + } + ], + "description": "", + "name": "test-job-include-raw-1" + } +] diff --git a/tests/loader/fixtures/include-raw-multi001.xml b/tests/loader/fixtures/include-raw-verbatim-multi-template.xml similarity index 83% rename from tests/loader/fixtures/include-raw-multi001.xml rename to tests/loader/fixtures/include-raw-verbatim-multi-template.xml index 5af950716..ba62d0292 100644 --- a/tests/loader/fixtures/include-raw-multi001.xml +++ b/tests/loader/fixtures/include-raw-verbatim-multi-template.xml @@ -13,7 +13,7 @@ #!/bin/bash # -# Sample script showing how the yaml include-raw tag can be used +# Sample script showing how the yaml !include-raw-verbatim: tag can be used # to inline scripts that are maintained outside of the jenkins # job yaml configuration. @@ -23,8 +23,8 @@ exit 0 #!/bin/bash # -# sample script to check that brackets aren't escaped -# when using the include-raw application yaml tag +# sample script to check that variables aren't expanded +# when using the !include-raw-verbatim: application yaml tag VAR1="hello" VAR2="world" diff --git a/tests/loader/fixtures/include-raw-escaped-multi001.yaml b/tests/loader/fixtures/include-raw-verbatim-multi-template.yaml similarity index 61% rename from tests/loader/fixtures/include-raw-escaped-multi001.yaml rename to tests/loader/fixtures/include-raw-verbatim-multi-template.yaml index 327d1a9f3..f29a287cc 100644 --- a/tests/loader/fixtures/include-raw-escaped-multi001.yaml +++ b/tests/loader/fixtures/include-raw-verbatim-multi-template.yaml @@ -2,9 +2,9 @@ name: test-job-include-raw-{num} builders: - shell: - !include-raw-escape: - - include-raw001-hello-world.sh - - include-raw001-vars.sh + !include-raw-verbatim: + - include-raw-hello-world.sh + - include-raw-vars.sh - project: name: test-job-template-1 diff --git a/tests/loader/fixtures/include-raw-verbatim-template.json b/tests/loader/fixtures/include-raw-verbatim-template.json new file mode 100644 index 000000000..d00e0189f --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-template.json @@ -0,0 +1,14 @@ +[ + { + "builders": [ + { + "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml !include-raw-verbatim: tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n" + }, + { + "shell": "#!/bin/bash\n#\n# sample script to check that variables aren't expanded\n# when using the !include-raw-verbatim: application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" + } + ], + "description": "", + "name": "test-include-raw-verbatim-job-1" + } +] diff --git a/tests/loader/fixtures/include-raw-verbatim-template.xml b/tests/loader/fixtures/include-raw-verbatim-template.xml new file mode 100644 index 000000000..f164110ec --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-template.xml @@ -0,0 +1,45 @@ + + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + #!/bin/bash +# +# Sample script showing how the yaml !include-raw-verbatim: tag can be used +# to inline scripts that are maintained outside of the jenkins +# job yaml configuration. + +echo "hello world" + +exit 0 + + + + #!/bin/bash +# +# sample script to check that variables aren't expanded +# when using the !include-raw-verbatim: application yaml tag + +VAR1="hello" +VAR2="world" +VAR3="${VAR1} ${VAR2}" + +[[ -n "${VAR3}" ]] && { + # this next section is executed as one + echo "${VAR3}" + exit 0 +} + + + + + + diff --git a/tests/loader/fixtures/include-raw-verbatim-template.yaml b/tests/loader/fixtures/include-raw-verbatim-template.yaml new file mode 100644 index 000000000..110ab852b --- /dev/null +++ b/tests/loader/fixtures/include-raw-verbatim-template.yaml @@ -0,0 +1,13 @@ +- job-template: + name: test-include-raw-verbatim-job-{num} + builders: + - shell: + !include-raw-verbatim: include-raw-hello-world.sh + - shell: + !include-raw-verbatim: include-raw-vars.sh + +- project: + name: test-job-template-1 + num: 1 + jobs: + - 'test-include-raw-verbatim-job-{num}' diff --git a/tests/loader/fixtures/include-raw001-job.json b/tests/loader/fixtures/include-raw001-job.json deleted file mode 100644 index 8ec298fde..000000000 --- a/tests/loader/fixtures/include-raw001-job.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "builders": [ - { - "shell": "#!/bin/bash\n#\n# Sample script showing how the yaml include-raw tag can be used\n# to inline scripts that are maintained outside of the jenkins\n# job yaml configuration.\n\necho \"hello world\"\n\nexit 0\n" - }, - { - "shell": "#!/bin/bash\n#\n# sample script to check that brackets aren't escaped\n# when using the include-raw application yaml tag\n\nVAR1=\"hello\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" - } - ], - "description": "", - "name": "test-job-include-raw-1" - } -] diff --git a/tests/loader/fixtures/include-raw001-job.yaml b/tests/loader/fixtures/include-raw001-job.yaml deleted file mode 100644 index ab718448f..000000000 --- a/tests/loader/fixtures/include-raw001-job.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- job: - name: test-job-include-raw-1 - builders: - - shell: - !include-raw-escape: include-raw001-hello-world.sh - - shell: - !include-raw-escape: include-raw001-vars.sh diff --git a/tests/loader/fixtures/include-raw001-template.json b/tests/loader/fixtures/include-raw001-template.json deleted file mode 100644 index d96b182b8..000000000 --- a/tests/loader/fixtures/include-raw001-template.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "builders": [ - { - "shell": "#!/bin/bash\n#\n# sample script to check that brackets aren't escaped\n# when using the include-raw application yaml tag\n\nVAR1=\"1\"\nVAR2=\"world\"\nVAR3=\"${VAR1} ${VAR2}\"\n\n[[ -n \"${VAR3}\" ]] && {\n # this next section is executed as one\n echo \"${VAR3}\"\n exit 0\n}\n" - } - ], - "description": "", - "name": "test-job-include-raw-1" - } -] diff --git a/tests/yamlparser/error_fixtures/include_raw_escape_missing_path.error b/tests/yamlparser/error_fixtures/include_raw_escape_missing_path.error deleted file mode 100644 index e7971efcb..000000000 --- a/tests/yamlparser/error_fixtures/include_raw_escape_missing_path.error +++ /dev/null @@ -1,9 +0,0 @@ -include_raw_escape_missing_path.yaml:7:3: In project 'sample-project' - - project: - ^ -include_raw_escape_missing_path.yaml:1:3: In job template 'sample-job' - - job-template: - ^ -include_raw_escape_missing_path.yaml:5:11: File missing-file.sh does not exist in any of include directories: .,fixtures-dir - !include-raw-escape: missing-file.sh - ^ diff --git a/tests/yamlparser/error_fixtures/include_raw_expand_missing_path.error b/tests/yamlparser/error_fixtures/include_raw_expand_missing_path.error new file mode 100644 index 000000000..13ed07487 --- /dev/null +++ b/tests/yamlparser/error_fixtures/include_raw_expand_missing_path.error @@ -0,0 +1,9 @@ +include_raw_expand_missing_path.yaml:7:3: In project 'sample-project' + - project: + ^ +include_raw_expand_missing_path.yaml:1:3: In job template 'sample-job' + - job-template: + ^ +include_raw_expand_missing_path.yaml:5:11: File missing-file.sh does not exist in any of include directories: .,fixtures-dir + !include-raw-expand: missing-file.sh + ^ diff --git a/tests/yamlparser/error_fixtures/include_raw_missing_path.yaml b/tests/yamlparser/error_fixtures/include_raw_expand_missing_path.yaml similarity index 73% rename from tests/yamlparser/error_fixtures/include_raw_missing_path.yaml rename to tests/yamlparser/error_fixtures/include_raw_expand_missing_path.yaml index 5f0b06bb4..1d29ca49d 100644 --- a/tests/yamlparser/error_fixtures/include_raw_missing_path.yaml +++ b/tests/yamlparser/error_fixtures/include_raw_expand_missing_path.yaml @@ -2,7 +2,7 @@ name: sample-job builders: - shell: - !include-raw: missing-file.sh + !include-raw-expand: missing-file.sh - project: name: sample-project diff --git a/tests/yamlparser/error_fixtures/include_raw_missing_path.error b/tests/yamlparser/error_fixtures/include_raw_missing_path.error deleted file mode 100644 index b85c3e88d..000000000 --- a/tests/yamlparser/error_fixtures/include_raw_missing_path.error +++ /dev/null @@ -1,9 +0,0 @@ -include_raw_missing_path.yaml:7:3: In project 'sample-project' - - project: - ^ -include_raw_missing_path.yaml:1:3: In job template 'sample-job' - - job-template: - ^ -include_raw_missing_path.yaml:5:11: File missing-file.sh does not exist in any of include directories: .,fixtures-dir - !include-raw: missing-file.sh - ^ diff --git a/tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.error b/tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.error new file mode 100644 index 000000000..321dac9dc --- /dev/null +++ b/tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.error @@ -0,0 +1,9 @@ +include_raw_verbatim_missing_path.yaml:7:3: In project 'sample-project' + - project: + ^ +include_raw_verbatim_missing_path.yaml:1:3: In job template 'sample-job' + - job-template: + ^ +include_raw_verbatim_missing_path.yaml:5:11: File missing-file.sh does not exist in any of include directories: .,fixtures-dir + !include-raw-verbatim: missing-file.sh + ^ diff --git a/tests/yamlparser/error_fixtures/include_raw_escape_missing_path.yaml b/tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.yaml similarity index 72% rename from tests/yamlparser/error_fixtures/include_raw_escape_missing_path.yaml rename to tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.yaml index 7eb243df5..1121f7f5d 100644 --- a/tests/yamlparser/error_fixtures/include_raw_escape_missing_path.yaml +++ b/tests/yamlparser/error_fixtures/include_raw_verbatim_missing_path.yaml @@ -2,7 +2,7 @@ name: sample-job builders: - shell: - !include-raw-escape: missing-file.sh + !include-raw-verbatim: missing-file.sh - project: name: sample-project diff --git a/tests/yamlparser/error_fixtures/missing_param_in_include_raw.error b/tests/yamlparser/error_fixtures/missing_param_in_include_raw.error deleted file mode 100644 index 1843b3a27..000000000 --- a/tests/yamlparser/error_fixtures/missing_param_in_include_raw.error +++ /dev/null @@ -1,10 +0,0 @@ -missing_param_in_include_raw.yaml:6:3: In project 'sample-project' - - project: - ^ -missing_param_in_include_raw.yaml:1:3: In job template 'sample-job' - - job-template: - ^ -missing_param_in_include_raw.yaml:4:16: In included file 'missing_param_in_include_raw.inc' - - shell: !include-raw: missing_param_in_include_raw.inc - ^ -While formatting string '#!/bin/bash\necho "This one is {missing}!"\n...': Missing parameter: 'missing' diff --git a/tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.error b/tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.error new file mode 100644 index 000000000..888732d24 --- /dev/null +++ b/tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.error @@ -0,0 +1,10 @@ +missing_param_in_include_raw_expand.yaml:6:3: In project 'sample-project' + - project: + ^ +missing_param_in_include_raw_expand.yaml:1:3: In job template 'sample-job' + - job-template: + ^ +missing_param_in_include_raw_expand.yaml:4:16: In included file 'missing_param_in_include_raw_expand.inc' + - shell: !include-raw-expand: missing_param_in_include ... + ^ +While formatting string '#!/bin/bash\necho "This one is {missing}!"\n...': Missing parameter: 'missing' diff --git a/tests/yamlparser/error_fixtures/missing_param_in_include_raw.inc b/tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.inc similarity index 100% rename from tests/yamlparser/error_fixtures/missing_param_in_include_raw.inc rename to tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.inc diff --git a/tests/yamlparser/error_fixtures/missing_param_in_include_raw.yaml b/tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.yaml similarity index 60% rename from tests/yamlparser/error_fixtures/missing_param_in_include_raw.yaml rename to tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.yaml index 4062d7680..6159a22f7 100644 --- a/tests/yamlparser/error_fixtures/missing_param_in_include_raw.yaml +++ b/tests/yamlparser/error_fixtures/missing_param_in_include_raw_expand.yaml @@ -1,7 +1,7 @@ - job-template: name: sample-job builders: - - shell: !include-raw: missing_param_in_include_raw.inc + - shell: !include-raw-expand: missing_param_in_include_raw_expand.inc - project: name: sample-project diff --git a/tests/yamlparser/error_fixtures/nested_brace_in_variable.yaml b/tests/yamlparser/error_fixtures/nested_brace_in_variable.yaml index d9c6a5d37..68ab40ef1 100644 --- a/tests/yamlparser/error_fixtures/nested_brace_in_variable.yaml +++ b/tests/yamlparser/error_fixtures/nested_brace_in_variable.yaml @@ -1,5 +1,5 @@ # Check braces inside variable does not cause parser to fail. -# This may happen when tag !include-raw: is used instead of !include-raw-escape: +# This may happen when tag !include-raw-expand: is used instead of !include-raw-verbatim: # and there are nested blocks of groovy code inside included file. - job-template: diff --git a/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.hello-world.sh b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.hello-world.sh new file mode 100644 index 000000000..800110d8d --- /dev/null +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.hello-world.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Sample script showing how the yaml include-raw-escape tag can be used +# to inline scripts that are maintained outside of the jenkins +# job yaml configuration. + +echo "hello world" + +exit 0 diff --git a/tests/loader/fixtures/include-raw001-vars.sh b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.vars.sh similarity index 59% rename from tests/loader/fixtures/include-raw001-vars.sh rename to tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.vars.sh index 2e33779a0..eb935564f 100644 --- a/tests/loader/fixtures/include-raw001-vars.sh +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.vars.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# sample script to check that brackets aren't escaped -# when using the include-raw application yaml tag +# sample script to check that brackets aren't expanded +# when using the include-raw-escape application yaml tag VAR1="hello" VAR2="world" diff --git a/tests/loader/fixtures/include-raw001-job.xml b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.xml similarity index 85% rename from tests/loader/fixtures/include-raw001-job.xml rename to tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.xml index 9a48dc3d9..28a36363b 100644 --- a/tests/loader/fixtures/include-raw001-job.xml +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.xml @@ -13,7 +13,7 @@ #!/bin/bash # -# Sample script showing how the yaml include-raw tag can be used +# Sample script showing how the yaml include-raw-escape tag can be used # to inline scripts that are maintained outside of the jenkins # job yaml configuration. @@ -25,8 +25,8 @@ exit 0 #!/bin/bash # -# sample script to check that brackets aren't escaped -# when using the include-raw application yaml tag +# sample script to check that brackets aren't expanded +# when using the include-raw-escape application yaml tag VAR1="hello" VAR2="world" diff --git a/tests/loader/fixtures/include-raw-escaped001-template.yaml b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.yaml similarity index 56% rename from tests/loader/fixtures/include-raw-escaped001-template.yaml rename to tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.yaml index df4668282..7dcbbf7ab 100644 --- a/tests/loader/fixtures/include-raw-escaped001-template.yaml +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw-escaped002.yaml @@ -2,9 +2,9 @@ name: test-job-include-raw-{num} builders: - shell: - !include-raw-escape: include-raw001-hello-world.sh + !include-raw-escape: deprecated-include-raw-escaped002.hello-world.sh - shell: - !include-raw-escape: include-raw001-vars.sh + !include-raw-escape: deprecated-include-raw-escaped002.vars.sh - project: name: test-job-template-1 diff --git a/tests/loader/fixtures/include-raw001-hello-world.sh b/tests/yamlparser/job_fixtures/deprecated-include-raw002.hello-world.sh similarity index 100% rename from tests/loader/fixtures/include-raw001-hello-world.sh rename to tests/yamlparser/job_fixtures/deprecated-include-raw002.hello-world.sh diff --git a/tests/loader/fixtures/include-raw001-parameterized.sh b/tests/yamlparser/job_fixtures/deprecated-include-raw002.vars.sh similarity index 75% rename from tests/loader/fixtures/include-raw001-parameterized.sh rename to tests/yamlparser/job_fixtures/deprecated-include-raw002.vars.sh index 2dc9a5927..a5fa6008c 100644 --- a/tests/loader/fixtures/include-raw001-parameterized.sh +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw002.vars.sh @@ -1,9 +1,9 @@ #!/bin/bash # -# sample script to check that brackets aren't escaped +# sample script to check that brackets aren't expanded # when using the include-raw application yaml tag -VAR1="{num}" +VAR1="hello" VAR2="world" VAR3="${{VAR1}} ${{VAR2}}" diff --git a/tests/loader/fixtures/include-raw-escaped001-job.xml b/tests/yamlparser/job_fixtures/deprecated-include-raw002.xml similarity index 95% rename from tests/loader/fixtures/include-raw-escaped001-job.xml rename to tests/yamlparser/job_fixtures/deprecated-include-raw002.xml index 9a48dc3d9..a1b3e42e0 100644 --- a/tests/loader/fixtures/include-raw-escaped001-job.xml +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw002.xml @@ -25,7 +25,7 @@ exit 0 #!/bin/bash # -# sample script to check that brackets aren't escaped +# sample script to check that brackets aren't expanded # when using the include-raw application yaml tag VAR1="hello" diff --git a/tests/yamlparser/job_fixtures/deprecated-include-raw002.yaml b/tests/yamlparser/job_fixtures/deprecated-include-raw002.yaml new file mode 100644 index 000000000..c5d463b81 --- /dev/null +++ b/tests/yamlparser/job_fixtures/deprecated-include-raw002.yaml @@ -0,0 +1,7 @@ +- job: + name: test-job-include-raw-1 + builders: + - shell: + !include-raw: deprecated-include-raw002.hello-world.sh + - shell: + !include-raw: deprecated-include-raw002.vars.sh diff --git a/tests/yamlparser/job_fixtures/include-raw-expand-cool.sh b/tests/yamlparser/job_fixtures/include-raw-expand-cool.sh new file mode 100644 index 000000000..6b72b6ae5 --- /dev/null +++ b/tests/yamlparser/job_fixtures/include-raw-expand-cool.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "Doing somethiung cool" diff --git a/tests/yamlparser/job_fixtures/include-raw002-cool.zsh b/tests/yamlparser/job_fixtures/include-raw-expand-cool.zsh similarity index 100% rename from tests/yamlparser/job_fixtures/include-raw002-cool.zsh rename to tests/yamlparser/job_fixtures/include-raw-expand-cool.zsh diff --git a/tests/yamlparser/job_fixtures/include-rawunicode001-cool.sh b/tests/yamlparser/job_fixtures/include-raw-expand-unicode-cool.sh similarity index 100% rename from tests/yamlparser/job_fixtures/include-rawunicode001-cool.sh rename to tests/yamlparser/job_fixtures/include-raw-expand-unicode-cool.sh diff --git a/tests/yamlparser/job_fixtures/include-rawunicode001.xml b/tests/yamlparser/job_fixtures/include-raw-expand-unicode.xml similarity index 100% rename from tests/yamlparser/job_fixtures/include-rawunicode001.xml rename to tests/yamlparser/job_fixtures/include-raw-expand-unicode.xml diff --git a/tests/yamlparser/job_fixtures/include-rawunicode001.yaml b/tests/yamlparser/job_fixtures/include-raw-expand-unicode.yaml similarity index 76% rename from tests/yamlparser/job_fixtures/include-rawunicode001.yaml rename to tests/yamlparser/job_fixtures/include-raw-expand-unicode.yaml index f74724027..3ff78ced3 100644 --- a/tests/yamlparser/job_fixtures/include-rawunicode001.yaml +++ b/tests/yamlparser/job_fixtures/include-raw-expand-unicode.yaml @@ -4,7 +4,7 @@ - pre-scm-buildstep: buildsteps: - shell: - !include-raw: include-rawunicode001-cool.sh + !include-raw-expand: include-raw-expand-unicode-cool.sh - job: name: test-unicode-raw-include-wrapper diff --git a/tests/yamlparser/job_fixtures/include-raw001.xml b/tests/yamlparser/job_fixtures/include-raw-expand.xml similarity index 100% rename from tests/yamlparser/job_fixtures/include-raw001.xml rename to tests/yamlparser/job_fixtures/include-raw-expand.xml diff --git a/tests/yamlparser/job_fixtures/include-raw001.yaml b/tests/yamlparser/job_fixtures/include-raw-expand.yaml similarity index 88% rename from tests/yamlparser/job_fixtures/include-raw001.yaml rename to tests/yamlparser/job_fixtures/include-raw-expand.yaml index de5e44bb8..7d7492dc9 100644 --- a/tests/yamlparser/job_fixtures/include-raw001.yaml +++ b/tests/yamlparser/job_fixtures/include-raw-expand.yaml @@ -14,9 +14,9 @@ - pre-scm-buildstep: buildsteps: - shell: - !include-raw: include-raw002-cool.sh + !include-raw-expand: include-raw-expand-cool.sh - shell: - !include-raw: include-raw002-cool.zsh + !include-raw-expand: include-raw-expand-cool.zsh - ant: targets: "target1 target2" ant-name: "Standard Ant" diff --git a/tests/yamlparser/job_fixtures/include-raw-escape001-echo-vars.sh b/tests/yamlparser/job_fixtures/include-raw-verbatim-echo-vars.sh similarity index 72% rename from tests/yamlparser/job_fixtures/include-raw-escape001-echo-vars.sh rename to tests/yamlparser/job_fixtures/include-raw-verbatim-echo-vars.sh index 31e8743dd..86ae430bc 100644 --- a/tests/yamlparser/job_fixtures/include-raw-escape001-echo-vars.sh +++ b/tests/yamlparser/job_fixtures/include-raw-verbatim-echo-vars.sh @@ -1,7 +1,7 @@ #!/bin/bash # # test script containing some variables to show how you can include scripts -# into job template definitions provided you use the include-raw-escaped tag +# into job template definitions provided you use the !include-raw-verbatim: tag MSG="hello world" diff --git a/tests/yamlparser/job_fixtures/include-raw-escape001.conf b/tests/yamlparser/job_fixtures/include-raw-verbatim.conf similarity index 100% rename from tests/yamlparser/job_fixtures/include-raw-escape001.conf rename to tests/yamlparser/job_fixtures/include-raw-verbatim.conf diff --git a/tests/yamlparser/job_fixtures/include-raw-escape001.xml b/tests/yamlparser/job_fixtures/include-raw-verbatim.xml similarity index 94% rename from tests/yamlparser/job_fixtures/include-raw-escape001.xml rename to tests/yamlparser/job_fixtures/include-raw-verbatim.xml index 2f4cd343a..df88edfe0 100644 --- a/tests/yamlparser/job_fixtures/include-raw-escape001.xml +++ b/tests/yamlparser/job_fixtures/include-raw-verbatim.xml @@ -30,7 +30,7 @@ #!/bin/bash # # test script containing some variables to show how you can include scripts -# into job template definitions provided you use the include-raw-escaped tag +# into job template definitions provided you use the !include-raw-verbatim: tag MSG="hello world" diff --git a/tests/yamlparser/job_fixtures/include-raw-escape001.yaml b/tests/yamlparser/job_fixtures/include-raw-verbatim.yaml similarity index 84% rename from tests/yamlparser/job_fixtures/include-raw-escape001.yaml rename to tests/yamlparser/job_fixtures/include-raw-verbatim.yaml index ecbf69f15..054a78251 100644 --- a/tests/yamlparser/job_fixtures/include-raw-escape001.yaml +++ b/tests/yamlparser/job_fixtures/include-raw-verbatim.yaml @@ -11,7 +11,7 @@ keep-system-variables: true builders: - shell: - !include-raw-escape: include-raw-escape001-echo-vars.sh + !include-raw-verbatim: include-raw-verbatim-echo-vars.sh - project: diff --git a/tests/yamlparser/job_fixtures/jinja-yaml03.yaml b/tests/yamlparser/job_fixtures/jinja-yaml03.yaml index 06a32b5be..1fd0abb1a 100644 --- a/tests/yamlparser/job_fixtures/jinja-yaml03.yaml +++ b/tests/yamlparser/job_fixtures/jinja-yaml03.yaml @@ -1,13 +1,13 @@ # the purpose of this test is to check if the piece of YAML generated by # !j2-yaml is deep-formatted properly; if not then double quotes introduced by -# !include-raw-escape would be left untouched and passed down to the output XML +# !include-raw-verbatim: would be left untouched and passed down to the output XML # file, which would simply be wrong... - job-template: name: 'test-job-template' publishers: !j2-yaml: | - groovy-postbuild: - script: !include-raw-escape: ./jinja-yaml03.groovy + script: !include-raw-verbatim: ./jinja-yaml03.groovy - project: name: test-project diff --git a/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml index fa68acc12..eea1cec4a 100644 --- a/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml +++ b/tests/yamlparser/job_fixtures/job-and-macro-expansions.yaml @@ -10,7 +10,7 @@ builders: - shell: | echo Should not be expanded: {{param}} - - shell: !include-raw-escape: job-and-macro-expansions.yaml.no-expand.inc + - shell: !include-raw-verbatim: job-and-macro-expansions.yaml.no-expand.inc - builder: name: builder-with-params @@ -19,8 +19,8 @@ echo Should not be expanded: {{param}} - shell: | echo Should be expanded: {param} - - shell: !include-raw-escape: job-and-macro-expansions.yaml.no-expand.inc - - shell: !include-raw: job-and-macro-expansions.yaml.expand.inc + - shell: !include-raw-verbatim: job-and-macro-expansions.yaml.no-expand.inc + - shell: !include-raw-expand: job-and-macro-expansions.yaml.expand.inc - job: name: sample-job @@ -28,7 +28,7 @@ builders: - shell: | echo Should not be expanded: {{param}} - - shell: !include-raw-escape: job-and-macro-expansions.yaml.no-expand.inc + - shell: !include-raw-verbatim: job-and-macro-expansions.yaml.no-expand.inc - job-template: name: sample-job-template @@ -41,8 +41,8 @@ echo Should not be expanded: {{param}} - shell: | echo Should be expanded: {param} - - shell: !include-raw-escape: job-and-macro-expansions.yaml.no-expand.inc - - shell: !include-raw: job-and-macro-expansions.yaml.expand.inc + - shell: !include-raw-verbatim: job-and-macro-expansions.yaml.no-expand.inc + - shell: !include-raw-expand: job-and-macro-expansions.yaml.expand.inc - project: name: sample-project diff --git a/tests/yamlparser/job_fixtures/lazy-load-jobs-multi001.yaml b/tests/yamlparser/job_fixtures/lazy-load-jobs-multi001.yaml index d5cfce62f..826fd6f18 100644 --- a/tests/yamlparser/job_fixtures/lazy-load-jobs-multi001.yaml +++ b/tests/yamlparser/job_fixtures/lazy-load-jobs-multi001.yaml @@ -15,6 +15,6 @@ !include: lazy-load-wrappers-{version}.yaml.inc builders: - shell: - !include-raw-escape: + !include-raw-verbatim: - lazy-load-scripts/echo_vars_{version}.sh - include-raw{num}-cool.sh diff --git a/tests/yamlparser/job_fixtures/lazy-load-jobs-multi002.yaml b/tests/yamlparser/job_fixtures/lazy-load-jobs-multi002.yaml index 668ff0ad1..f59102a96 100644 --- a/tests/yamlparser/job_fixtures/lazy-load-jobs-multi002.yaml +++ b/tests/yamlparser/job_fixtures/lazy-load-jobs-multi002.yaml @@ -2,7 +2,7 @@ name: "test-job-{job_name}" builders: - shell: - !include-raw-escape: 'lazy-load-scripts/echo_vars_{job_name}.sh' + !include-raw-verbatim: 'lazy-load-scripts/echo_vars_{job_name}.sh' - project: name: 'test-project' diff --git a/tests/yamlparser/job_fixtures/lazy-load-jobs001.yaml b/tests/yamlparser/job_fixtures/lazy-load-jobs001.yaml index 0c7bbac2f..1a9869987 100644 --- a/tests/yamlparser/job_fixtures/lazy-load-jobs001.yaml +++ b/tests/yamlparser/job_fixtures/lazy-load-jobs001.yaml @@ -14,4 +14,4 @@ !include: lazy-load-wrappers-{version}.yaml.inc builders: - shell: - !include-raw-escape: echo_vars_{version}.sh + !include-raw-verbatim: echo_vars_{version}.sh diff --git a/tests/yamlparser/job_fixtures/lazy-load-jobs002.yaml b/tests/yamlparser/job_fixtures/lazy-load-jobs002.yaml index 0e7d6e71d..6974d5b07 100644 --- a/tests/yamlparser/job_fixtures/lazy-load-jobs002.yaml +++ b/tests/yamlparser/job_fixtures/lazy-load-jobs002.yaml @@ -20,4 +20,4 @@ !include lazy-load-wrappers-{version}.yaml.inc builders: - shell: - !include-raw-escape: lazy-load-scripts/echo_vars_{version}.sh + !include-raw-verbatim: lazy-load-scripts/echo_vars_{version}.sh diff --git a/tests/yamlparser/job_fixtures/lazy-load-with-variables.yaml b/tests/yamlparser/job_fixtures/lazy-load-with-variables.yaml index 8ed7f4916..c262a369a 100644 --- a/tests/yamlparser/job_fixtures/lazy-load-with-variables.yaml +++ b/tests/yamlparser/job_fixtures/lazy-load-with-variables.yaml @@ -5,7 +5,7 @@ name: 'sample-job-{version}' builders: - shell: - !include-raw: lazy-load-scripts/subst_vars_{version}.sh + !include-raw-expand: lazy-load-scripts/subst_vars_{version}.sh - project: name: sample-project diff --git a/tests/yamlparser/job_fixtures/regression-2006254.yaml b/tests/yamlparser/job_fixtures/regression-2006254.yaml index 2bab04613..ad2fe2bed 100644 --- a/tests/yamlparser/job_fixtures/regression-2006254.yaml +++ b/tests/yamlparser/job_fixtures/regression-2006254.yaml @@ -25,7 +25,7 @@ - timed: "H 14 * * *" builders: - - shell: !include-raw-escape: regression-2006254.inc + - shell: !include-raw-verbatim: regression-2006254.inc parameters: - bool: diff --git a/tests/yamlparser/job_fixtures/regression-2007227.yaml b/tests/yamlparser/job_fixtures/regression-2007227.yaml index 80a86bd84..d89bb0851 100644 --- a/tests/yamlparser/job_fixtures/regression-2007227.yaml +++ b/tests/yamlparser/job_fixtures/regression-2007227.yaml @@ -1,10 +1,10 @@ # https://storyboard.openstack.org/#!/story/2007227 -# with Python 3 there is TypeError when include-raw with property replacement is used in defaults +# with Python 3 there is TypeError when !include-raw-expand: with property replacement is used in defaults - defaults: name: 'test-defaults' prop: 'regression-2007227.description' - description: !include-raw: + description: !include-raw-expand: - '{prop}.html' - project: diff --git a/tests/yamlparser/job_fixtures/regression-2010711/job_1/job_1.yaml b/tests/yamlparser/job_fixtures/regression-2010711/job_1/job_1.yaml index 661bc1e41..f90687f0a 100644 --- a/tests/yamlparser/job_fixtures/regression-2010711/job_1/job_1.yaml +++ b/tests/yamlparser/job_fixtures/regression-2010711/job_1/job_1.yaml @@ -5,7 +5,7 @@ name: sample-job-1 description: sample-job-1 builders: - - shell: !include-raw-escape: sample_file.sh + - shell: !include-raw-verbatim: sample_file.sh - project: name: sample-project-1 diff --git a/tests/yamlparser/job_fixtures/regression-2010711/job_2/job_2.yaml b/tests/yamlparser/job_fixtures/regression-2010711/job_2/job_2.yaml index a7a1ee4bd..5f546ca93 100644 --- a/tests/yamlparser/job_fixtures/regression-2010711/job_2/job_2.yaml +++ b/tests/yamlparser/job_fixtures/regression-2010711/job_2/job_2.yaml @@ -5,7 +5,7 @@ name: sample-job-2 description: sample-job-2 builders: - - shell: !include-raw-escape: sample_file.sh + - shell: !include-raw-verbatim: sample_file.sh - project: name: sample-project-2 diff --git a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.inc.txt b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.inc.txt similarity index 100% rename from tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.inc.txt rename to tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.inc.txt diff --git a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.xml b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.xml similarity index 100% rename from tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.xml rename to tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.xml diff --git a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.yaml b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.yaml similarity index 57% rename from tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.yaml rename to tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.yaml index 3db4a86e4..273ba9681 100644 --- a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-escape.yaml +++ b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-expand.yaml @@ -1,8 +1,8 @@ -# !include-raw-escape: tag in a variable. +# !include-raw-expand: tag in a variable. - job-template: name: sample-job - var: !include-raw-escape: tag_in_parameter-include-raw-escape.inc.txt + var: !include-raw-expand: tag_in_parameter-include-raw-expand.inc.txt builders: - shell: | echo {var} diff --git a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.inc.txt b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.inc.txt similarity index 100% rename from tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.inc.txt rename to tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.inc.txt diff --git a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.xml b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.xml similarity index 100% rename from tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.xml rename to tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.xml diff --git a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.yaml b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.yaml similarity index 56% rename from tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.yaml rename to tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.yaml index cf5bceeff..7b95c97fe 100644 --- a/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw.yaml +++ b/tests/yamlparser/job_fixtures/tag_in_parameter-include-raw-verbatim.yaml @@ -1,8 +1,8 @@ -# !include-raw: tag in a variable. +# !include-raw-verbatim: tag in a variable. - job-template: name: sample-job - var: !include-raw: tag_in_parameter-include-raw.inc.txt + var: !include-raw-verbatim: tag_in_parameter-include-raw-verbatim.inc.txt builders: - shell: | echo {var}