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
This commit is contained in:
Vsevolod Fedorov 2024-02-06 11:49:10 +03:00
parent 3cf741985f
commit 36b9d8bfca
76 changed files with 296 additions and 202 deletions

View File

@ -23,8 +23,8 @@ from .yaml_objects import (
YamlInclude, YamlInclude,
YamlListJoin, YamlListJoin,
IncludeJinja2, IncludeJinja2,
IncludeRaw, IncludeRawExpand,
IncludeRawEscape, IncludeRawVerbatim,
) )
@ -92,14 +92,16 @@ yaml_classes_list = [
YamlInclude, YamlInclude,
YamlListJoin, YamlListJoin,
IncludeJinja2, IncludeJinja2,
IncludeRaw, IncludeRawExpand,
IncludeRawEscape, IncludeRawVerbatim,
] ]
deprecated_yaml_tags = [ deprecated_yaml_tags = [
("!include", YamlInclude), ("!include", YamlInclude),
("!include-raw", IncludeRaw), ("!include-raw", IncludeRawExpand),
("!include-raw-escape", IncludeRawEscape), ("!include-raw:", IncludeRawExpand),
("!include-raw-escape", IncludeRawVerbatim),
("!include-raw-escape:", IncludeRawVerbatim),
] ]

View File

@ -78,34 +78,34 @@ Example:
.. literalinclude:: /../../tests/loader/fixtures/include001.yaml.inc .. literalinclude:: /../../tests/loader/fixtures/include001.yaml.inc
The tag ``!include-raw:`` will treat the given string or list of strings as The tag ``!include-raw-expand:`` will treat the given string or list of strings
filenames to be opened as one or more data blob, which should be read into 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 the calling yaml construct without any further parsing. Any data in a file
included through this tag, will be treated as string data. included through this tag, will be treated as string data.
It will expand variables inside the file. If your file contains curly braces, 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. does not substitute variables.
Examples: Examples:
.. literalinclude:: .. 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:: .. 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:: .. 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:: .. 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 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)) return "\n".join(self._expand_path_list(self._path_list, params))
class IncludeRaw(IncludeRawBase): class IncludeRawExpand(IncludeRawBase):
yaml_tag = "!include-raw:" yaml_tag = "!include-raw-expand:"
def _expand_path(self, rel_path_template, pos, params): def _expand_path(self, rel_path_template, pos, params):
rel_path = self._formatter.format(rel_path_template, **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) raise x.with_context(f"In included file {str(full_path)!r}", pos=self._pos)
class IncludeRawEscape(IncludeRawBase): class IncludeRawVerbatim(IncludeRawBase):
yaml_tag = "!include-raw-escape:" yaml_tag = "!include-raw-verbatim:"
def _expand_path(self, rel_path_template, pos, params): def _expand_path(self, rel_path_template, pos, params):
rel_path = self._formatter.format(rel_path_template, **params) rel_path = self._formatter.format(rel_path_template, **params)

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw"
}
]

View File

@ -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

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -13,8 +13,8 @@
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/bin/bash
# #
# sample script to check that brackets aren't escaped # sample script to check that variables are expanded
# when using the include-raw application yaml tag # when using the !include-raw-expand: application yaml tag
VAR1=&quot;1&quot; VAR1=&quot;1&quot;
VAR2=&quot;world&quot; VAR2=&quot;world&quot;

View File

@ -2,7 +2,7 @@
name: test-job-include-raw-{num} name: test-job-include-raw-{num}
builders: builders:
- shell: - shell:
!include-raw: include-raw001-parameterized.sh !include-raw-expand: include-raw-parameterized.sh
- project: - project:
name: test-job-template name: test-job-template

View File

@ -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

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -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

View File

@ -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
}}

View File

@ -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
}

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-include-raw-verbatim-job"
}
]

View File

@ -13,7 +13,7 @@
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/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 # to inline scripts that are maintained outside of the jenkins
# job yaml configuration. # job yaml configuration.
@ -25,8 +25,8 @@ exit 0
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/bin/bash
# #
# sample script to check that brackets aren't escaped # sample script to check that variables aren't expanded
# when using the include-raw application yaml tag # when using the !include-raw-verbatim: application yaml tag
VAR1=&quot;hello&quot; VAR1=&quot;hello&quot;
VAR2=&quot;world&quot; VAR2=&quot;world&quot;

View File

@ -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

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-verbatim-multi-001"
}
]

View File

@ -13,7 +13,7 @@
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/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 # to inline scripts that are maintained outside of the jenkins
# job yaml configuration. # job yaml configuration.
@ -23,8 +23,8 @@ exit 0
#!/bin/bash #!/bin/bash
# #
# sample script to check that brackets aren't escaped # sample script to check that variables aren't expanded
# when using the include-raw application yaml tag # when using the !include-raw-verbatim: application yaml tag
VAR1=&quot;hello&quot; VAR1=&quot;hello&quot;
VAR2=&quot;world&quot; VAR2=&quot;world&quot;

View File

@ -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

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -13,7 +13,7 @@
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/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 # to inline scripts that are maintained outside of the jenkins
# job yaml configuration. # job yaml configuration.
@ -23,8 +23,8 @@ exit 0
#!/bin/bash #!/bin/bash
# #
# sample script to check that brackets aren't escaped # sample script to check that variables aren't expanded
# when using the include-raw application yaml tag # when using the !include-raw-verbatim: application yaml tag
VAR1=&quot;hello&quot; VAR1=&quot;hello&quot;
VAR2=&quot;world&quot; VAR2=&quot;world&quot;

View File

@ -2,9 +2,9 @@
name: test-job-include-raw-{num} name: test-job-include-raw-{num}
builders: builders:
- shell: - shell:
!include-raw-escape: !include-raw-verbatim:
- include-raw001-hello-world.sh - include-raw-hello-world.sh
- include-raw001-vars.sh - include-raw-vars.sh
- project: - project:
name: test-job-template-1 name: test-job-template-1

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-include-raw-verbatim-job-1"
}
]

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>#!/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 &quot;hello world&quot;
exit 0
</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>#!/bin/bash
#
# sample script to check that variables aren't expanded
# when using the !include-raw-verbatim: application yaml tag
VAR1=&quot;hello&quot;
VAR2=&quot;world&quot;
VAR3=&quot;${VAR1} ${VAR2}&quot;
[[ -n &quot;${VAR3}&quot; ]] &amp;&amp; {
# this next section is executed as one
echo &quot;${VAR3}&quot;
exit 0
}
</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

View File

@ -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}'

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -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

View File

@ -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": "<!-- Managed by Jenkins Job Builder -->",
"name": "test-job-include-raw-1"
}
]

View File

@ -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
^

View File

@ -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
^

View File

@ -2,7 +2,7 @@
name: sample-job name: sample-job
builders: builders:
- shell: - shell:
!include-raw: missing-file.sh !include-raw-expand: missing-file.sh
- project: - project:
name: sample-project name: sample-project

View File

@ -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
^

View File

@ -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
^

View File

@ -2,7 +2,7 @@
name: sample-job name: sample-job
builders: builders:
- shell: - shell:
!include-raw-escape: missing-file.sh !include-raw-verbatim: missing-file.sh
- project: - project:
name: sample-project name: sample-project

View File

@ -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'

View File

@ -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'

View File

@ -1,7 +1,7 @@
- job-template: - job-template:
name: sample-job name: sample-job
builders: builders:
- shell: !include-raw: missing_param_in_include_raw.inc - shell: !include-raw-expand: missing_param_in_include_raw_expand.inc
- project: - project:
name: sample-project name: sample-project

View File

@ -1,5 +1,5 @@
# Check braces inside variable does not cause parser to fail. # 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. # and there are nested blocks of groovy code inside included file.
- job-template: - job-template:

View File

@ -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

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/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 # when using the include-raw-escape application yaml tag
VAR1="hello" VAR1="hello"
VAR2="world" VAR2="world"

View File

@ -13,7 +13,7 @@
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/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 # to inline scripts that are maintained outside of the jenkins
# job yaml configuration. # job yaml configuration.
@ -25,8 +25,8 @@ exit 0
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/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 # when using the include-raw-escape application yaml tag
VAR1=&quot;hello&quot; VAR1=&quot;hello&quot;
VAR2=&quot;world&quot; VAR2=&quot;world&quot;

View File

@ -2,9 +2,9 @@
name: test-job-include-raw-{num} name: test-job-include-raw-{num}
builders: builders:
- shell: - shell:
!include-raw-escape: include-raw001-hello-world.sh !include-raw-escape: deprecated-include-raw-escaped002.hello-world.sh
- shell: - shell:
!include-raw-escape: include-raw001-vars.sh !include-raw-escape: deprecated-include-raw-escaped002.vars.sh
- project: - project:
name: test-job-template-1 name: test-job-template-1

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/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 # when using the include-raw application yaml tag
VAR1="{num}" VAR1="hello"
VAR2="world" VAR2="world"
VAR3="${{VAR1}} ${{VAR2}}" VAR3="${{VAR1}} ${{VAR2}}"

View File

@ -25,7 +25,7 @@ exit 0
<hudson.tasks.Shell> <hudson.tasks.Shell>
<command>#!/bin/bash <command>#!/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 # when using the include-raw application yaml tag
VAR1=&quot;hello&quot; VAR1=&quot;hello&quot;

View File

@ -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

View File

@ -0,0 +1,2 @@
#!/bin/bash
echo "Doing somethiung cool"

View File

@ -4,7 +4,7 @@
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps: buildsteps:
- shell: - shell:
!include-raw: include-rawunicode001-cool.sh !include-raw-expand: include-raw-expand-unicode-cool.sh
- job: - job:
name: test-unicode-raw-include-wrapper name: test-unicode-raw-include-wrapper

View File

@ -14,9 +14,9 @@
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps: buildsteps:
- shell: - shell:
!include-raw: include-raw002-cool.sh !include-raw-expand: include-raw-expand-cool.sh
- shell: - shell:
!include-raw: include-raw002-cool.zsh !include-raw-expand: include-raw-expand-cool.zsh
- ant: - ant:
targets: "target1 target2" targets: "target1 target2"
ant-name: "Standard Ant" ant-name: "Standard Ant"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# test script containing some variables to show how you can include scripts # 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" MSG="hello world"

View File

@ -30,7 +30,7 @@
<command>#!/bin/bash <command>#!/bin/bash
# #
# test script containing some variables to show how you can include scripts # 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=&quot;hello world&quot; MSG=&quot;hello world&quot;

View File

@ -11,7 +11,7 @@
keep-system-variables: true keep-system-variables: true
builders: builders:
- shell: - shell:
!include-raw-escape: include-raw-escape001-echo-vars.sh !include-raw-verbatim: include-raw-verbatim-echo-vars.sh
- project: - project:

View File

@ -1,13 +1,13 @@
# the purpose of this test is to check if the piece of YAML generated by # 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 # !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... # file, which would simply be wrong...
- job-template: - job-template:
name: 'test-job-template' name: 'test-job-template'
publishers: !j2-yaml: | publishers: !j2-yaml: |
- groovy-postbuild: - groovy-postbuild:
script: !include-raw-escape: ./jinja-yaml03.groovy script: !include-raw-verbatim: ./jinja-yaml03.groovy
- project: - project:
name: test-project name: test-project

View File

@ -10,7 +10,7 @@
builders: builders:
- shell: | - shell: |
echo Should not be expanded: {{param}} 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: - builder:
name: builder-with-params name: builder-with-params
@ -19,8 +19,8 @@
echo Should not be expanded: {{param}} echo Should not be expanded: {{param}}
- shell: | - shell: |
echo Should be expanded: {param} echo Should 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
- shell: !include-raw: job-and-macro-expansions.yaml.expand.inc - shell: !include-raw-expand: job-and-macro-expansions.yaml.expand.inc
- job: - job:
name: sample-job name: sample-job
@ -28,7 +28,7 @@
builders: builders:
- shell: | - shell: |
echo Should not be expanded: {{param}} 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: - job-template:
name: sample-job-template name: sample-job-template
@ -41,8 +41,8 @@
echo Should not be expanded: {{param}} echo Should not be expanded: {{param}}
- shell: | - shell: |
echo Should be expanded: {param} echo Should 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
- shell: !include-raw: job-and-macro-expansions.yaml.expand.inc - shell: !include-raw-expand: job-and-macro-expansions.yaml.expand.inc
- project: - project:
name: sample-project name: sample-project

View File

@ -15,6 +15,6 @@
!include: lazy-load-wrappers-{version}.yaml.inc !include: lazy-load-wrappers-{version}.yaml.inc
builders: builders:
- shell: - shell:
!include-raw-escape: !include-raw-verbatim:
- lazy-load-scripts/echo_vars_{version}.sh - lazy-load-scripts/echo_vars_{version}.sh
- include-raw{num}-cool.sh - include-raw{num}-cool.sh

View File

@ -2,7 +2,7 @@
name: "test-job-{job_name}" name: "test-job-{job_name}"
builders: builders:
- shell: - shell:
!include-raw-escape: 'lazy-load-scripts/echo_vars_{job_name}.sh' !include-raw-verbatim: 'lazy-load-scripts/echo_vars_{job_name}.sh'
- project: - project:
name: 'test-project' name: 'test-project'

View File

@ -14,4 +14,4 @@
!include: lazy-load-wrappers-{version}.yaml.inc !include: lazy-load-wrappers-{version}.yaml.inc
builders: builders:
- shell: - shell:
!include-raw-escape: echo_vars_{version}.sh !include-raw-verbatim: echo_vars_{version}.sh

View File

@ -20,4 +20,4 @@
!include lazy-load-wrappers-{version}.yaml.inc !include lazy-load-wrappers-{version}.yaml.inc
builders: builders:
- shell: - shell:
!include-raw-escape: lazy-load-scripts/echo_vars_{version}.sh !include-raw-verbatim: lazy-load-scripts/echo_vars_{version}.sh

View File

@ -5,7 +5,7 @@
name: 'sample-job-{version}' name: 'sample-job-{version}'
builders: builders:
- shell: - shell:
!include-raw: lazy-load-scripts/subst_vars_{version}.sh !include-raw-expand: lazy-load-scripts/subst_vars_{version}.sh
- project: - project:
name: sample-project name: sample-project

View File

@ -25,7 +25,7 @@
- timed: "H 14 * * *" - timed: "H 14 * * *"
builders: builders:
- shell: !include-raw-escape: regression-2006254.inc - shell: !include-raw-verbatim: regression-2006254.inc
parameters: parameters:
- bool: - bool:

View File

@ -1,10 +1,10 @@
# https://storyboard.openstack.org/#!/story/2007227 # 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: - defaults:
name: 'test-defaults' name: 'test-defaults'
prop: 'regression-2007227.description' prop: 'regression-2007227.description'
description: !include-raw: description: !include-raw-expand:
- '{prop}.html' - '{prop}.html'
- project: - project:

View File

@ -5,7 +5,7 @@
name: sample-job-1 name: sample-job-1
description: sample-job-1 description: sample-job-1
builders: builders:
- shell: !include-raw-escape: sample_file.sh - shell: !include-raw-verbatim: sample_file.sh
- project: - project:
name: sample-project-1 name: sample-project-1

View File

@ -5,7 +5,7 @@
name: sample-job-2 name: sample-job-2
description: sample-job-2 description: sample-job-2
builders: builders:
- shell: !include-raw-escape: sample_file.sh - shell: !include-raw-verbatim: sample_file.sh
- project: - project:
name: sample-project-2 name: sample-project-2

View File

@ -1,8 +1,8 @@
# !include-raw-escape: tag in a variable. # !include-raw-expand: tag in a variable.
- job-template: - job-template:
name: sample-job 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: builders:
- shell: | - shell: |
echo {var} echo {var}

View File

@ -1,8 +1,8 @@
# !include-raw: tag in a variable. # !include-raw-verbatim: tag in a variable.
- job-template: - job-template:
name: sample-job 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: builders:
- shell: | - shell: |
echo {var} echo {var}