gecko-dev/taskcluster/docs/yaml-templates.rst
Dustin J. Mitchell c1ccda957f Bug 1275409: move templates to taskgraph.util; r=wcosta
MozReview-Commit-ID: 3vdnm20W4OD

--HG--
rename : taskcluster/taskgraph/test/test_util.py => taskcluster/taskgraph/test/test_util_docker.py
rename : testing/taskcluster/tests/test_templates.py => taskcluster/taskgraph/test/test_util_templates.py
rename : taskcluster/taskgraph/util.py => taskcluster/taskgraph/util/__init__.py
rename : testing/taskcluster/taskcluster_graph/templates.py => taskcluster/taskgraph/util/templates.py
extra : rebase_source : 6d098d87e715b82c0dcd5bf03beb7646bbd50fe2
2016-06-05 18:34:22 +00:00

46 lines
1.6 KiB
ReStructuredText

Task Definition YAML Templates
==============================
Many kinds of tasks are described using YAML files. These files allow some
limited forms of inheritance and template substitution as well as the usual
YAML features, as described below.
Please use these features sparingly. In many cases, it is better to add a
feature to the implementation of a task kind rather than add complexity to the
YAML files.
Inheritance
-----------
One YAML file can "inherit" from another by including a top-level ``$inherits``
key. That key specifies the parent file in ``from``, and optionally a
collection of variables in ``variables``. For example:
.. code-block:: yaml
$inherits:
from: 'tasks/builds/base_linux32.yml'
variables:
build_name: 'linux32'
build_type: 'dbg'
Inheritance proceeds as follows: First, the child document has its template
substitutions performed and is parsed as YAML. Then, the parent document is
parsed, with substitutions specified by ``variables`` added to the template
substitutions. Finally, the child document is merged with the parent.
To merge two JSON objects (dictionaries), each value is merged individually.
Lists are merged by concatenating the lists from the parent and child
documents. Atomic values (strings, numbers, etc.) are merged by preferring the
child document's value.
Substitution
------------
Each document is expanded using the PyStache template engine before it is
parsed as YAML. The parameters for this expansion are specific to the task
kind.
Simple value substitution looks like ``{{variable}}``. Function calls look
like ``{{#function}}argument{{/function}}``.