YAML / GUI introduction

Buddy allows you to configure pipelines in two ways:

  1. GUI - configuration is performed via website or API
  2. YAML - configuration is performed via buddy.yml located in the repository

By default, the mode is set to GUI. This part of documentation will explain how to activate and use YAML configuration with Buddy.

How to switch the config mode to YAML

The mode can be switched in one of two ways:

  • If there aren’t any pipelines in the project, just push buddy.yml to the repository
  • If the pipelines already exist, go to Pipelines, flip the switch to YAML, and push buddy.yml to the repo.

Please mind that once you switch to YAML all pipelines in the project will be removed. They will be reproduced back again as soon as the config file has been pushed to the repo.

How to switch the config mode to GUI

If you have a project where you used YAML before but want to configure the pipelines with the GUI again, just flip the switch back to GUI:

Switching YAML to GUI

Buddy.yml and branches

Pipelines are defined in the buddy.yml file. Pushing the file to the branch X will reconfigure:

  • all pipelines whose ref_name is set to branch X
  • all pipelines whose ref_name is set to a wildcard matching branch X
  • all pipelines whose ref_name is set to None in the GUI, provided that branch X is the default branch

Pushing the file with tag X will reconfigure:

  • all pipelines whose ref_name is set to tag X
  • all pipelines whose ref_name is set to a wildcard matching tag X

YAML helper

To make the configuration easier you can use the YAML Helper to:

  • dump the configuration of the pipelines defined in the project
  • define a pipeline in the GUI so you can see how it should look in YAML
  • define an action in the GUI so you can see how it should look in YAML

Generating a new action

Once you configure the action details, click Generate YAML:

Generating YAML

After that, a pop-up with the generated YAML will appear:

Action configured in YAML

Pipelines in the .yml file are defined in the form of a list. Here’s an example config file with definitions of two pipelines:

YAML

- pipeline: "production"
trigger_mode: "MANUAL"
ref_name: "master"
actions:
- action: "Execute: npm test"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "6"
execute_commands:
- "npm install"
- "npm test"
setup_commands:
- "npm install -g gulp grunt-cli"
- action: "Upload files to winserver.sls"
type: "FTP"
input_type: "BUILD_ARTIFACTS"
local_path: "/"
login: "pass"
password: "testtest"
host: "winserver.sls"
port: "21"
- pipeline: "build server"
trigger_mode: "ON_EVERY_PUSH"
ref_name: "*"
actions:
- action: "Execute: npm test"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "6"
execute_commands:
- "npm install"
- "npm test"
setup_commands:
- "npm install -g gulp grunt-cli"

The schema for pipelines and actions is described in details in the next article.

Multiple YAML-file support

Users that have many pipelines in a single project can split the definitions into multiple files that Buddy will read and parse:

  1. The buddy.yml file in the root folder of the repository (this doesn't change)
  2. All *.yml files in the .buddy directory

If a pipeline with the same ID is defined in several entries and/or files, the pipeline will be configured according to the last definition in line (files are processed alphabetically).

  • YAML syntax does not change
  • There is no limit on the number of pipelines per file

Encrypted variables

To encrypt the variables in yaml you need to set a salt in Workspace Preferences first: Setting encryption salt

Then use the YAML helper to generate encrypted values for your buddy.yml: Generating an encrypted value

Solving problems

If the pipeline definition in buddy.yml is incorrect, the pipeline will not be added. In order to debug what went wrong, follow these steps:

  1. Go to the project’s Activity stream
  2. Find the push containing the commit with the new version of buddy.yml

Clicking the commit will launch the logs covering the process of the file:

YAML processing logs