Document use of | character for variable defaults

Change-Id: Id20fc7a49fef6684170a73834f2df06db3f0ca7f
Signed-off-by: Thanh Ha <zxiiro@linux.com>
This commit is contained in:
Thanh Ha 2018-04-13 13:38:05 -04:00
parent 82f2ab4417
commit 90663ea8a6
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
3 changed files with 65 additions and 0 deletions

View File

@ -474,6 +474,16 @@ For example, having a configuration file with that option enabled:
Will prevent JJb from failing if there are any non-initialized variables used
and replace them with the empty string instead.
.. tip::
Defaults for variables can be set by using the ``|`` character
``{var|default_value}``. This is useful if we want to allow users of the
job-template to not have to pass a setting if there is a common default for
it.
Example:
.. literalinclude:: /../../tests/yamlparser/fixtures/variable_defaults.yaml
Yaml Anchors & Aliases
^^^^^^^^^^^^^^^^^^^^^^

View File

@ -0,0 +1,39 @@
<?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>echo yolo</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>
<BLANKLINE>
<?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>echo override</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

View File

@ -0,0 +1,16 @@
- job-template:
name: '{name}-variable-defaults'
builders:
- shell: '{script|echo yolo}'
- project:
name: default
jobs:
- '{name}-variable-defaults'
- project:
name: override
jobs:
- '{name}-variable-defaults'
script: echo override