Templates

pipeline.yaml puts the power of Go templates at your fingertips. At runtime and during pipeline.yaml template evaluation, you can use any environment variable that's been injected by the CI/CD engine.

You can also use the same Sprig template functions you use in Helm.

Some notable examples of how to use Golang templates are:

  • Using trunc to create a short commit hash:
build_container:
  image: plugins/docker
  repo: '{{ .CICD_REPO }}'
  tags: '{{ trunc 7 .CICD_COMMIT_SHA }}'
  • Using derivePassword to generate a password:
deployment:
  name: './spotguide-nodejs-mongodb-1.0.0.tgz'
  reuseValues: true
  releaseName: '{{ .CICD_REPO_NAME }}'
  values:
    application:
      password: {{ derivePassword 1 "long" .CICD_COMMIT_BRANCH "user" .DOMAIN_NAME }}
  • Using conditional statements:
{{if some-condition}}
deployment_application_to_production:
  image: banzaicloud/ci-pipeline-client:0.7
  action: EnsureDeployment
  deployment:
    name: './spotguide-nodejs-mongodb-1.0.0.tgz'
    reuseValues: true
    releaseName: '{{ .CICD_REPO_NAME }}'
{{else}}
deployment_application_to_pre_prod:
  image: banzaicloud/ci-pipeline-client:0.7
  action: EnsureDeployment
  deployment:
    name: './spotguide-nodejs-mongodb-1.0.0.tgz'
    reuseValues: true
    releaseName: '{{ .CICD_REPO_NAME }}'
{{end}}