Platform Vars
Example Go template with platform 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
Platform variables can be referenced with the following syntax:
{{ vela "<environment variable>" }}
Examples
{{ vela "VELA_REPO_NAME" }}
equates to theVELA_REPO_NAME
environment variable{{ vela "REPO_NAME" }}
equates to theVELA_REPO_NAME
environment variable{{ vela "VELA_BUILD_NUMBER" }}
equates to theVELA_BUILD_NUMBER
environment variable{{ vela "VELA_ADDR" }}
equates to theVELA_ADDR
environment variable{{ vela "DEPLOYMENT_PARAMETER_<name>" }}
equates to theDEPLOYMENT_PARAMETER_<name>
environment variable
Sample
Let’s take a look at using a platform variable in a template:
metadata:
template: true
steps:
- name: test
commands:
- echo {{ vela "VELA_REPO_FULL_NAME" }}
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
Which means the compiled pipeline for execution on a worker is:
version: "1"
steps:
- name: sample_echo
commands:
- echo github/octocat
image: alpine
pull: always
ruleset:
event: [ push, pull_request ]
Last modified December 13, 2022: enhance(templates): add deployment parameter details (#306) (e58dd418)