Merge "Document use of | character for variable defaults"

This commit is contained in:
Zuul 2018-04-25 15:46:57 +00:00 committed by Gerrit Code Review
commit 96f112e915
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