Story 2011112: include-raw-verbatim fails on job-template
don't expand IncludeRawVerbatim twice > FAILED tests/loader/test_loader.py::test_include_job[include002] - jenkins_jobs.errors.JenkinsJobsException: While formatting string "#!/bin/bash\n#\n# sample script to check that variables aren't expanded\n# when usi...": Missing parameter: 'VAR1' > FAILED tests/loader/test_loader.py::test_include[include002] - jenkins_jobs.errors.JenkinsJobsException: While formatting string "#!/bin/bash\n#\n# sample script to check that variables aren't expanded\n# when usi...": Missing parameter: 'VAR1' Change-Id: I88b22987eabe99f00d99755299256d4aba8a1c76
This commit is contained in:
parent
9c38f33a4b
commit
4897d5e047
@ -143,12 +143,13 @@ class Expander:
|
|||||||
|
|
||||||
# Expand only yaml objects.
|
# Expand only yaml objects.
|
||||||
class YamlObjectsExpander(Expander):
|
class YamlObjectsExpander(Expander):
|
||||||
def __init__(self):
|
def __init__(self, config=None):
|
||||||
super().__init__()
|
super().__init__(config)
|
||||||
self.expanders.update(
|
self.expanders.update(
|
||||||
{
|
{
|
||||||
str: dont_expand,
|
str: dont_expand,
|
||||||
LocString: dont_expand,
|
LocString: dont_expand,
|
||||||
|
IncludeRawVerbatim: dont_expand,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from functools import partial
|
|||||||
from .errors import JenkinsJobsException
|
from .errors import JenkinsJobsException
|
||||||
from .loc_loader import LocLoader
|
from .loc_loader import LocLoader
|
||||||
from .yaml_objects import BaseYamlObject
|
from .yaml_objects import BaseYamlObject
|
||||||
from .expander import Expander, deprecated_yaml_tags, yaml_classes_list
|
from .expander import YamlObjectsExpander, deprecated_yaml_tags, yaml_classes_list
|
||||||
from .roots import root_adders
|
from .roots import root_adders
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -118,7 +118,7 @@ def enum_expanded_paths(path_list):
|
|||||||
|
|
||||||
|
|
||||||
def load_files(config, roots, path_list):
|
def load_files(config, roots, path_list):
|
||||||
expander = Expander(config)
|
expander = YamlObjectsExpander(config)
|
||||||
loader = Loader.empty(config)
|
loader = Loader.empty(config)
|
||||||
for path in enum_expanded_paths(path_list):
|
for path in enum_expanded_paths(path_list):
|
||||||
if is_stdin(path):
|
if is_stdin(path):
|
||||||
|
14
tests/yamlparser/job_fixtures/include-raw-vars.sh
Normal file
14
tests/yamlparser/job_fixtures/include-raw-vars.sh
Normal 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
|
||||||
|
}
|
33
tests/yamlparser/job_fixtures/include002.xml
Normal file
33
tests/yamlparser/job_fixtures/include002.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<actions/>
|
||||||
|
<description><!-- Managed by Jenkins Job Builder --></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 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
|
||||||
|
}
|
||||||
|
</command>
|
||||||
|
</hudson.tasks.Shell>
|
||||||
|
</builders>
|
||||||
|
<publishers/>
|
||||||
|
<buildWrappers/>
|
||||||
|
</project>
|
6
tests/yamlparser/job_fixtures/include002.yaml
Normal file
6
tests/yamlparser/job_fixtures/include002.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# using !include in job-template
|
||||||
|
- job-template: !include: include002.yaml.inc
|
||||||
|
- project:
|
||||||
|
name: acc-cdi
|
||||||
|
jobs:
|
||||||
|
- test-gerrit
|
4
tests/yamlparser/job_fixtures/include002.yaml.inc
Normal file
4
tests/yamlparser/job_fixtures/include002.yaml.inc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name: test-gerrit
|
||||||
|
builders:
|
||||||
|
- shell:
|
||||||
|
!include-raw-verbatim: include-raw-vars.sh
|
Loading…
x
Reference in New Issue
Block a user