diff options
author | James Harris <james.harris@garmin.com> | 2019-08-22 15:09:36 -0500 |
---|---|---|
committer | James Harris <james.harris@garmin.com> | 2019-11-05 23:33:57 -0600 |
commit | 8c19ca0cd20a1b039c15c70bb313a07d5784ddd1 (patch) | |
tree | d954077d9cb7b235b84139a4ffb84ccb40c9b457 /tests/yamlparser/fixtures | |
parent | b27399c477e5d5331c59aa341b734f5901a7fffe (diff) | |
download | python-jenkins-job-builder-8c19ca0cd20a1b039c15c70bb313a07d5784ddd1.tar.gz python-jenkins-job-builder-8c19ca0cd20a1b039c15c70bb313a07d5784ddd1.tar.xz python-jenkins-job-builder-8c19ca0cd20a1b039c15c70bb313a07d5784ddd1.zip |
Fix double inderection of name templates
Ensure that we can resolve any lazily loaded templates that might be
dictionary keys in yaml. For more informmation please see the added test
case in tests/yamlparser/fixtures/jinja-string04.yaml.
Change-Id: I67fbca422f2165729af15e4d039278ad66f6240b
Story: 2006431
Task: 36338
Diffstat (limited to 'tests/yamlparser/fixtures')
-rw-r--r-- | tests/yamlparser/fixtures/jinja-string04.xml | 19 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/jinja-string04.yaml | 40 |
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/yamlparser/fixtures/jinja-string04.xml b/tests/yamlparser/fixtures/jinja-string04.xml new file mode 100644 index 00000000..c61fef92 --- /dev/null +++ b/tests/yamlparser/fixtures/jinja-string04.xml @@ -0,0 +1,19 @@ +<?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>123</command> + </hudson.tasks.Shell> + </builders> + <publishers/> + <buildWrappers/> +</project> diff --git a/tests/yamlparser/fixtures/jinja-string04.yaml b/tests/yamlparser/fixtures/jinja-string04.yaml new file mode 100644 index 00000000..436ed55a --- /dev/null +++ b/tests/yamlparser/fixtures/jinja-string04.yaml @@ -0,0 +1,40 @@ +# Make sure Jinja subsittuions work from within "defaults" +- defaults: + name: test-defaults + test_var: + !j2: "{% for x in [1, 2, 3] %}{{ x }}{% endfor %}" + use_test_builder: true + test_builder_name: + !j2: | + {% if use_test_builder -%} + test-shell-builder-alternate + {%- else -%} + test-shell-builder-default + {%- endif %} + +- project: + name: test-proj + jobs: + - test-jobs-{argument}: + argument: + - 1 + +# This type of variable propagation only works in job templates. +- job-template: + name: test-jobs-{argument} + defaults: test-defaults + builders: + # This fails because we only render the initial template, not the final template. + - "{test_builder_name}": + test_var: "{test_var}" + +- builder: + name: test-shell-builder-alternate + builders: + - shell: "{test_var}" + + +- builder: + name: test-shell-builder-default + builders: + - shell: "default" |