diff options
author | Daniel Watkins <daniel.watkins@canonical.com> | 2017-07-31 17:46:57 -0400 |
---|---|---|
committer | Daniel Watkins <daniel.watkins@canonical.com> | 2017-08-09 10:11:42 -0400 |
commit | b95f194612029bfdb191da044e9a2b7e03ef3552 (patch) | |
tree | a7614d2cbdcf8d90a4cd659f44c0d8f40b34c4bb /tests/yamlparser/fixtures | |
parent | 2c60aff80675c50baf1fe132b92cfd4232be0cfa (diff) | |
download | python-jenkins-job-builder-b95f194612029bfdb191da044e9a2b7e03ef3552.tar.gz python-jenkins-job-builder-b95f194612029bfdb191da044e9a2b7e03ef3552.tar.xz python-jenkins-job-builder-b95f194612029bfdb191da044e9a2b7e03ef3552.zip |
Add !include-jinja2 for rendering templates with Jinja2
This template included using !include-jinja2:
"""
{{ my_var }}
"""
is rendered the same as an existing template that looks like this:
"""
{my_var}
"""
This also allows the use of Jinja2's richer syntax:
"""
{% for test_environment in configuration.get("envs", ["py35"]) %}
tox -e {{ test_environment }}
{% endfor %}
"""
Story: 2001135
Change-Id: Ia3ee21822d6e9237f5ea46796bc8810ecac61e2c
Diffstat (limited to 'tests/yamlparser/fixtures')
-rw-r--r-- | tests/yamlparser/fixtures/jinja01.xml | 23 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/jinja01.yaml | 15 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/jinja01.yaml.inc | 4 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/jinja02.xml | 19 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/jinja02.yaml | 11 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/jinja02.yaml.inc | 1 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/lazy-load-jinja001.xml | 23 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/lazy-load-jinja001.yaml | 16 |
8 files changed, 112 insertions, 0 deletions
diff --git a/tests/yamlparser/fixtures/jinja01.xml b/tests/yamlparser/fixtures/jinja01.xml new file mode 100644 index 00000000..de5ed018 --- /dev/null +++ b/tests/yamlparser/fixtures/jinja01.xml @@ -0,0 +1,23 @@ +<?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>test variable +a +b +c +</command> + </hudson.tasks.Shell> + </builders> + <publishers/> + <buildWrappers/> +</project> diff --git a/tests/yamlparser/fixtures/jinja01.yaml b/tests/yamlparser/fixtures/jinja01.yaml new file mode 100644 index 00000000..6106b69a --- /dev/null +++ b/tests/yamlparser/fixtures/jinja01.yaml @@ -0,0 +1,15 @@ +- builder: + name: test-builder + builders: + - shell: + !include-jinja2: jinja01.yaml.inc + +- job: + name: test-job + builders: + - test-builder: + var: "test variable" + test_list: + - a + - b + - c diff --git a/tests/yamlparser/fixtures/jinja01.yaml.inc b/tests/yamlparser/fixtures/jinja01.yaml.inc new file mode 100644 index 00000000..1f7c7926 --- /dev/null +++ b/tests/yamlparser/fixtures/jinja01.yaml.inc @@ -0,0 +1,4 @@ +{{ var }} +{% for item in test_list -%} +{{ item }} +{% endfor %} diff --git a/tests/yamlparser/fixtures/jinja02.xml b/tests/yamlparser/fixtures/jinja02.xml new file mode 100644 index 00000000..d0e1c909 --- /dev/null +++ b/tests/yamlparser/fixtures/jinja02.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>1</command> + </hudson.tasks.Shell> + </builders> + <publishers/> + <buildWrappers/> +</project> diff --git a/tests/yamlparser/fixtures/jinja02.yaml b/tests/yamlparser/fixtures/jinja02.yaml new file mode 100644 index 00000000..1e1d8747 --- /dev/null +++ b/tests/yamlparser/fixtures/jinja02.yaml @@ -0,0 +1,11 @@ +- job-template: + name: 'test-job-{num}' + builders: + - shell: + !include-jinja2: jinja02.yaml.inc + +- project: + name: test-job-template-1 + num: 1 + jobs: + - 'test-job-{num}' diff --git a/tests/yamlparser/fixtures/jinja02.yaml.inc b/tests/yamlparser/fixtures/jinja02.yaml.inc new file mode 100644 index 00000000..a535c742 --- /dev/null +++ b/tests/yamlparser/fixtures/jinja02.yaml.inc @@ -0,0 +1 @@ +{{ num }} diff --git a/tests/yamlparser/fixtures/lazy-load-jinja001.xml b/tests/yamlparser/fixtures/lazy-load-jinja001.xml new file mode 100644 index 00000000..de5ed018 --- /dev/null +++ b/tests/yamlparser/fixtures/lazy-load-jinja001.xml @@ -0,0 +1,23 @@ +<?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>test variable +a +b +c +</command> + </hudson.tasks.Shell> + </builders> + <publishers/> + <buildWrappers/> +</project> diff --git a/tests/yamlparser/fixtures/lazy-load-jinja001.yaml b/tests/yamlparser/fixtures/lazy-load-jinja001.yaml new file mode 100644 index 00000000..b1f7a63f --- /dev/null +++ b/tests/yamlparser/fixtures/lazy-load-jinja001.yaml @@ -0,0 +1,16 @@ +- builder: + name: test-builder + builders: + - shell: + !include-jinja2: jinja{include-number}.yaml.inc + +- job: + name: test-job + builders: + - test-builder: + var: "test variable" + test_list: + - a + - b + - c + include-number: "01" |