Template Vars

Example Golang template with template vars.

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 ]