YAML templates

The YAML templates, also known as remote YAML definitions, are templates with parameters that can be inherited by pipelines. This feature is useful to quickly set up new projects and update configuration across multiple pipelines at once.

Requirements and parameters

  1. One file equals one template. Each template needs to be created in a separate file.
  2. Parameters are defined just like environment variables, but instead of $ you provide !, e.g. !param1.
  3. In the inheriting pipeline, you define the parameter that will be swapped for a string.
  4. You can parameterize basically everything, from individual properties to whole actions. In the example below, you can see two parameters: !optionalaction and !awsintegration.

Example

- pipeline: "template"
  on: "EVENT"
  events:
  - type: "PUSH"
  refs:
  - "refs/heads/development"
  priority: "NORMAL"
  fail_on_prepare_env_warning: true
  actions:
  - action: "pwd"
    type: "BUILD"
    working_directory: "/buddy/git-repo"
    docker_image_name: "library/ubuntu"
    docker_image_tag: "18.04"
    execute_commands:
    - "pwd"
    volume_mappings:
    - "/:/buddy/git-repo"
    cache_base_image: true
    shell: "BASH"
!optionalaction
  - action: "cp bucket"
  type: "AWS_CLI_2"
  region: "us-east-1"
  execute_commands:
  - "aws s3 cp test.txt s3://mybucket/test2.txt"
  shell: "SH"
  integration_hash: "!awsintegration"

Inheriting pipeline configuration

The next step is to define the pipelines that will inherit from the template. In these pipelines, you provide:

  1. Pipeline name
  2. Definition_source: “REMOTE”
  3. Project, branch, and path to the template
  4. The list of parameters to swap in the child pipeline

Example

- pipeline: "child1"
  definition_source: "REMOTE"
  remote_path: "/t1.yml"
  remote_branch: "master"
  remote_project_name: "templates"
  remote_parameters:
  - key: "optionalaction"
    value: " - action: \"ls\"\n    type: \"BUILD\"\n    working_directory: \"/buddy/git-repo\"\n    docker_image_name: \"library/ubuntu\"\n    docker_image_tag: \"18.04\"\n    execute_commands:\n - \"ls\"\n    volume_mappings:\n    - \"/:/buddy/git-repo\"\n    cache_base_image: true\n     shell: \"BASH\""
  - key: "awsintegration"
    value: "vVP4XgELYqaQ5Vg5anjk2m9Oz7" 
- pipeline: "child2"
  definition_source: "REMOTE"
  remote_path: "/t1.yml"
  remote_branch: "master"
  remote_project_name: "templates"
  remote_parameters:
  - key: "optionalaction"
  value: ""
  - key: "awsintegration"
  value: "vVP4XgELYqaQ5Vg5anjk2m9Oz7"

GUI configuration

The parameters can also be defined from the GUI. To do that, switch the config mode to Remote YAML when adding a new pipeline, select the project, branch, and path to the template in the filesystem, and define the parameters below:

Remote YAML parameters in GUIRemote YAML parameters in GUI

Get Started

Sign up for free and deploy your project in less than 10 minutes.