summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJames Harris <james.harris@garmin.com>2019-08-22 14:19:16 -0500
committerJames Harris <james.harris@garmin.com>2019-11-05 20:18:28 -0600
commitb27399c477e5d5331c59aa341b734f5901a7fffe (patch)
tree7a377f6f763ec3ee27f3f85da91660e0e4fbb110 /tests
parentc56e325217a7488fa57eaf53c5d5f37d80a0051c (diff)
downloadpython-jenkins-job-builder-b27399c477e5d5331c59aa341b734f5901a7fffe.tar.gz
python-jenkins-job-builder-b27399c477e5d5331c59aa341b734f5901a7fffe.tar.xz
python-jenkins-job-builder-b27399c477e5d5331c59aa341b734f5901a7fffe.zip
Allow use of jinja templates in defaults
Jinja templates are not deep-copyable so they cannot be used in "defautls" sections or to pick defualts for job groups or projects. This works around the issue by waiting until we render the template to construct the template itself. Story: 2006431 Task: 36337 Change-Id: Ief31fdaac06bb14d0aaba71c8c0e658a7f861671
Diffstat (limited to 'tests')
-rw-r--r--tests/yamlparser/fixtures/jinja-string03.xml19
-rw-r--r--tests/yamlparser/fixtures/jinja-string03.yaml19
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/yamlparser/fixtures/jinja-string03.xml b/tests/yamlparser/fixtures/jinja-string03.xml
new file mode 100644
index 00000000..c61fef92
--- /dev/null
+++ b/tests/yamlparser/fixtures/jinja-string03.xml
@@ -0,0 +1,19 @@
+<?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>123</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers/>
+ <buildWrappers/>
+</project>
diff --git a/tests/yamlparser/fixtures/jinja-string03.yaml b/tests/yamlparser/fixtures/jinja-string03.yaml
new file mode 100644
index 00000000..28b6a1cf
--- /dev/null
+++ b/tests/yamlparser/fixtures/jinja-string03.yaml
@@ -0,0 +1,19 @@
+# Make sure Jinja subsittuions work from within "defaults"
+- defaults:
+ name: test-defaults
+ test_var:
+ !j2: "{% for x in [1, 2, 3] %}{{ x }}{% endfor %}"
+
+- 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:
+ - shell: "{test_var}"