YAML templates – Remote pipeline configuration
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
- One file equals one template. Each template needs to be created in a separate file.
- Parameters are defined just like environment variables, but instead of
$
you provide!
, e.g.!param1
. The default value for the remote pipeline parameters is!{param1:defaultValue}
. - In the inheriting pipeline, you define the parameter that will be swapped for a string.
- You can parameterize basically everything, from individual properties to whole actions. In the example below, you can see two parameters:
!optionalaction
and!awsintegration
.
Example
yaml- 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:
- Pipeline name
Definition_source: “REMOTE”
- Project, branch, and path to the template
- The list of parameters to swap in the child pipeline
Example
yaml- pipeline: "child1" definition_source: "REMOTE" remote_path: "/t1.yml" remote_branch: "master" remote_project_name: "templates" remote_parameters: - key: "optionalaction" value: |- - action: "ls" type: "BUILD" working_directory: "/buddy/git-repo" docker_image_name: "library/ubuntu" docker_image_tag: "18.04" execute_commands: - "ls" volume_mappings: - "/:/buddy/git-repo" cache_base_image: true 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:
Image loading...
Last modified on Sep 23, 2024