Changes to YAML and API

Changes to YAML and API
Danger
UPDATE: The grace period for the old model of fetching data in pipelines ended on June 9, 2020. See below for more details.

90% of features and integrations in Buddy are developed in response to popular demand. The most recent includes support for multiple-trigger conditions, a feature that required us to change the pipeline model in the REST API and YAML to have it shipped. The changes also enable triggering pipelines on new events, like creating and removing branches or issuing pull requests.

Hint
The update only affects on-premises installations in version 2.3.107 and above.
Warning
With the release of v2.3.107, we are starting a grace period during which the data will still be fetched in the old model by default. The period will end with the release of version 2.4.1, scheduled for May 19, 2021 (EDIT: We eventually prolonged the period until June 9).

What you need to know

Currently all responses return the following header:

X-Buddy-Media-Type: buddy.v1.0.0

To adjust your apps that use REST API with the new model, you will have to update it to version 1.1.0 (it will also be visible in responses):

X-Buddy-Media-Type: buddy.v1.1.0
Danger
Once the grace period is over, the old default header no longer be supported.

Trigger conditions

At the moment, the changes in the REST API and YAML involve the fields that are responsibe for setting up the trigger condition in the pipeline and/or action:

yaml
trigger_condition trigger_condition_paths trigger_variable_key trigger_variable_value trigger_hours trigger_days zone_id trigger_project_name trigger_pipeline_name

Those fields can now be replaced by the trigger conditions array:

yaml
trigger_condtion[] trigger_condtions

YAML example

Each array object has to be provided with the exact same fields:

yaml
trigger_conditions: - trigger_condition: "VAR_IS" trigger_variable_value: "expectedValue" trigger_variable_key: "myVar"

REST API example

Each array object has to be provided with the exact same fields:

json
"trigger_conditions": [ { "trigger_condition": "VAR_IS", "trigger_variable_value": "expectedValue", "trigger_variable_key": "myVar" } ]
Hint
Not sending trigger_conditions array, or sending an empty trigger_conditions: [] will be equivalent of the deprecated trigger_condition: ALWAYS

Trigger modes

  1. ref_type is no longer available
  2. trigger_mode has been replaced with on:
  3. Trigger mode values are replaced with new ones:

    • MANUALCLICK
    • ON_EVERY_PUSHEVENT
    • SCHEDULEDSCHEDULE
Warning
The change above also applies to the values of the BUDDY_EXECUTION_MODE variable in the pipeline execution.

For on: "CLICK" and on: "SCHEDULE", you can send a collection of refs for which the pipelines is to be executed. For example:

yaml
on: "CLICK" refs: - "refs/heads/dev"

For on: EVENT you need to send array of events:

yaml
on: "EVENT" events: - type: "PUSH" refs: - "refs/heads/dev"
Warning
Refs provided as a name of a brach or tag (e.g. master, tag1) are no longer supported.

Instead, you need to provide a full ref path. For example:

  • Master branch: refs/heads/master
  • Tag t1: refs/tags/t1
  • All branches: refs/heads/*
  • All pull requests: refs/pull/*
  • All refs *

YAML examples

Old:

yaml
- pipeline: "buddy" trigger_mode: "MANUAL" ref_type: "NONE"

New:

yaml
- pipeline: "buddy" on: "CLICK"

Old:

yaml
- pipeline: "buddy" trigger_mode: "MANUAL" ref_name: "master" ref_type: "BRANCH"

New:

YAML
- pipeline: "buddy" on: "CLICK" refs: - "refs/heads/master"

Old:

yaml
- pipeline: "buddy" trigger_mode: "ON_EVERY_PUSH" ref_name: "master" ref_type: "BRANCH"

New:

yaml
- pipeline: "buddy" on: "EVENT" events: - type: "PUSH" refs: - "refs/heads/master"

REST API examples

Old:

json
{ "name": "buddy", "trigger_mode": "MANUAL", "ref_type": "NONE" }

New:

json
{ "name": "buddy", "trigger_mode": "MANUAL", "on": "CLICK" }

Old:

json
{ "name": "buddy", "trigger_mode": "MANUAL", "ref_name": "master", "ref_type": "BRANCH" }

New:

json
{ "name": "buddy", "on": "CLICK", "refs": [ "refs/heads/master" ] }

Old:

JSON
{ "nam": "buddy", "trigger_mode": "ON_EVERY_PUSH", "ref_name": "master", "ref_type": "BRANCH" }

New:

json
{ "pipeline": "buddy", "on": "EVENT", "events": [ { "type": "PUSH", "refs": [ "refs/heads/master" ] } ] }

Changes to execution mode (API only)

  1. mode has been replaced with triggeredOn
  2. triggeredOn uses the same values as pipelines: CLICK, SCHEDULE, and EVENT
  3. During the grace period, data will be fetched in the old way by default
  4. If you want to use the new mode, please use the X-Buddy-Media-Type: buddy.v1.1.0 header
  5. Once the transition period ends, mode will no longer be supported and triggeredOn will become the default.
Hint
Once the grace period has finished, the REST API will only support the new model. YAML will continue to support both old and new.
Jarek Dylewski

Jarek Dylewski

Customer Support

A journalist and an SEO specialist trying to find himself in the unforgiving world of coders. Gamer, a non-fiction literature fan and obsessive carnivore. Jarek uses his talents to convert the programming lingo into a cohesive and approachable narration.

Apr 15th 2021
Share