Fix !include parsing with variable
Do not overwrite template string when parsing yaml. Story: 2000996 Change-Id: Id1b12be69c3994fa4108a9841c0128da9dc883ef
This commit is contained in:
parent
870045688b
commit
50fd0d2833
|
@ -433,8 +433,10 @@ class LazyLoader(object):
|
||||||
return "%s %s" % (self._cls.yaml_tag, self._node.value)
|
return "%s %s" % (self._cls.yaml_tag, self._node.value)
|
||||||
|
|
||||||
def format(self, *args, **kwargs):
|
def format(self, *args, **kwargs):
|
||||||
self._node.value = self._node.value.format(*args, **kwargs)
|
node = yaml.ScalarNode(
|
||||||
return self._cls.from_yaml(self._loader, self._node)
|
tag=self._node.tag,
|
||||||
|
value=self._node.value.format(*args, **kwargs))
|
||||||
|
return self._cls.from_yaml(self._loader, node)
|
||||||
|
|
||||||
|
|
||||||
def load(stream, **kwargs):
|
def load(stream, **kwargs):
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?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
|
||||||
|
#
|
||||||
|
# version 1.1 of the echo vars script
|
||||||
|
|
||||||
|
MSG="hello world"
|
||||||
|
VERSION="1.1"
|
||||||
|
|
||||||
|
[[ -n "${MSG}" ]] && {
|
||||||
|
# this next section is executed as one
|
||||||
|
echo "${MSG}"
|
||||||
|
echo "version: ${VERSION}"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
</command>
|
||||||
|
</hudson.tasks.Shell>
|
||||||
|
</builders>
|
||||||
|
<publishers/>
|
||||||
|
<buildWrappers/>
|
||||||
|
</project>
|
||||||
|
|
||||||
|
<?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
|
||||||
|
#
|
||||||
|
# version 1.2 of the echo vars script
|
||||||
|
|
||||||
|
MSG="hello world"
|
||||||
|
VERSION="1.2"
|
||||||
|
|
||||||
|
[[ -n "${MSG}" ]] && {
|
||||||
|
# this next section is executed as one
|
||||||
|
echo "${MSG}"
|
||||||
|
echo "version: ${VERSION}"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
</command>
|
||||||
|
</hudson.tasks.Shell>
|
||||||
|
</builders>
|
||||||
|
<publishers/>
|
||||||
|
<buildWrappers/>
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
- job-template:
|
||||||
|
name: "test-job-{job_name}"
|
||||||
|
builders:
|
||||||
|
- shell:
|
||||||
|
!include-raw: 'lazy-load-scripts/echo_vars_{job_name}.sh'
|
||||||
|
|
||||||
|
- project:
|
||||||
|
name: 'test-project'
|
||||||
|
job_name:
|
||||||
|
- 1.1
|
||||||
|
- 1.2
|
||||||
|
jobs:
|
||||||
|
- "test-job-{job_name}"
|
Loading…
Reference in New Issue