Skip to main content

Platform Vars

tip

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 the VELA_REPO_NAME environment variable
  • {{ vela "REPO_NAME" }} equates to the VELA_REPO_NAME environment variable
  • {{ vela "VELA_BUILD_NUMBER" }} equates to the VELA_BUILD_NUMBER environment variable
  • {{ vela "VELA_ADDR" }} equates to the VELA_ADDR environment variable
  • {{ vela "DEPLOYMENT_PARAMETER_<name>" }} equates to the DEPLOYMENT_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 ]