Template Vars
Example Golang template with template vars.
We recommend reviewing Go Templates documentation before attempting to create a template.
If you’re new to YAML we also recommend reviewing the YAML 1.2 spec for validation on syntax.
Overview
Template variables can be referenced with the following syntax:
{{ .name }}
Sample
Let’s take a look at using variables within a template:
metadata:
template: true
steps:
- name: test
commands:
- echo {{ .input }}
image: alpine
pull: always
ruleset:
event: [ push, pull_request ]
The caller of this template could look like:
version: "1"
templates:
- name: sample
source: github.com/<org>/<repo>/path/to/file/<template>.yml
type: github
steps:
- name: sample
template:
name: echo
vars:
input: hello
Which means the compiled pipeline for execution on a worker is:
version: "1"
steps:
- name: sample_echo
commands:
- echo hello
image: alpine
pull: always
ruleset:
event: [ push, pull_request ]
Last modified August 1, 2022: docs(template): add vars page to match starlark (#308) (c85fd9b4)