summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-04-25 15:46:57 +0000
committerGerrit Code Review <review@openstack.org>2018-04-25 15:46:57 +0000
commit96f112e915977afd25be1a1e8d3c257a4c768297 (patch)
tree8bfff0de1db6fc0da14ca1dd6e4135f7c0bdafac
parentb66f8d1d6526810fde3eda9f58d8f5371afc79ca (diff)
parent90663ea8a631688aa32630651828ad8b205f2dbf (diff)
Merge "Document use of | character for variable defaults"
-rw-r--r--doc/source/definition.rst10
-rw-r--r--tests/yamlparser/fixtures/variable_defaults.xml39
-rw-r--r--tests/yamlparser/fixtures/variable_defaults.yaml16
3 files changed, 65 insertions, 0 deletions
diff --git a/doc/source/definition.rst b/doc/source/definition.rst
index 0fcb5c4..2361a50 100644
--- a/doc/source/definition.rst
+++ b/doc/source/definition.rst
@@ -474,6 +474,16 @@ For example, having a configuration file with that option enabled:
474Will prevent JJb from failing if there are any non-initialized variables used 474Will prevent JJb from failing if there are any non-initialized variables used
475and replace them with the empty string instead. 475and replace them with the empty string instead.
476 476
477.. tip::
478
479 Defaults for variables can be set by using the ``|`` character
480 ``{var|default_value}``. This is useful if we want to allow users of the
481 job-template to not have to pass a setting if there is a common default for
482 it.
483
484 Example:
485
486 .. literalinclude:: /../../tests/yamlparser/fixtures/variable_defaults.yaml
477 487
478Yaml Anchors & Aliases 488Yaml Anchors & Aliases
479^^^^^^^^^^^^^^^^^^^^^^ 489^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/yamlparser/fixtures/variable_defaults.xml b/tests/yamlparser/fixtures/variable_defaults.xml
new file mode 100644
index 0000000..74128ad
--- /dev/null
+++ b/tests/yamlparser/fixtures/variable_defaults.xml
@@ -0,0 +1,39 @@
1<?xml version="1.0" encoding="utf-8"?>
2<project>
3 <actions/>
4 <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
5 <keepDependencies>false</keepDependencies>
6 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
7 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
8 <concurrentBuild>false</concurrentBuild>
9 <canRoam>true</canRoam>
10 <properties/>
11 <scm class="hudson.scm.NullSCM"/>
12 <builders>
13 <hudson.tasks.Shell>
14 <command>echo yolo</command>
15 </hudson.tasks.Shell>
16 </builders>
17 <publishers/>
18 <buildWrappers/>
19</project>
20<BLANKLINE>
21<?xml version="1.0" encoding="utf-8"?>
22<project>
23 <actions/>
24 <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
25 <keepDependencies>false</keepDependencies>
26 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
27 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
28 <concurrentBuild>false</concurrentBuild>
29 <canRoam>true</canRoam>
30 <properties/>
31 <scm class="hudson.scm.NullSCM"/>
32 <builders>
33 <hudson.tasks.Shell>
34 <command>echo override</command>
35 </hudson.tasks.Shell>
36 </builders>
37 <publishers/>
38 <buildWrappers/>
39</project>
diff --git a/tests/yamlparser/fixtures/variable_defaults.yaml b/tests/yamlparser/fixtures/variable_defaults.yaml
new file mode 100644
index 0000000..ea25c6c
--- /dev/null
+++ b/tests/yamlparser/fixtures/variable_defaults.yaml
@@ -0,0 +1,16 @@
1- job-template:
2 name: '{name}-variable-defaults'
3
4 builders:
5 - shell: '{script|echo yolo}'
6
7- project:
8 name: default
9 jobs:
10 - '{name}-variable-defaults'
11
12- project:
13 name: override
14 jobs:
15 - '{name}-variable-defaults'
16 script: echo override