How to use YAML Templates in buildkite?

I’ve been looking at the docs but I couldn’t find it.

Hey @Joe good question.

This page here discusses pipeline steps and yaml with a few examples: Defining your pipeline steps | Buildkite Documentation

Hope that helps. Let us know if you need more info

Will step default also work with plugins

agents:
  queue: "something"
plugins:
  - plugin1:
       config-1:
  - plugin2:
       config-2:

steps:
  - command: "blah.sh"
  - command: "blahblah.sh"
  - label: "Yada"
    command: "yada.sh"
    agents:
      queue: "other"
    plugins:
     - plugin1:
          config-1: "other"

Ohh another good question!

You can’t define a default plugin list like this. But you can make use of YAML anchors to define such a plugin once and reference it where ever it is needed. Take a look at YAML anchors | Bitbucket Cloud | Atlassian Support to see how to use them

1 Like

Hi, jarryd

Does the plugins step syntax work with objects? yaml anchors do not work with arrays.

Below will turn the plugins into object type

definitions:
    plugins: &allplugins
      - plugin1: &plugin1
           config-1:
      - plugin2: 
           config-2:

steps:
  - label: "Yada"
    command: "yada.sh"
    plugins: 
        <<: *allplugins
        plugin1: 
            <<: *plugin1
            config-2:

My use of anchors ends with the <<: operator to extend/override things so I’m not too sure.
I found this that might help though assets - Is there a way to alias/anchor an array in YAML? - Stack Overflow which has a different way of putting the anchors on the list items.

I’m not sure if it does deep merging either but you could test it out. Something like this (not tested)

definitions:
    plugins: &allplugins
      - plugin1: &plugin1
           config-1:
      - plugin2: 
           config-2:

steps:
  - label: "Yada"
    command: "yada.sh"
    <<: *allplugins
    plugins: 
        plugin1: 
            <<: *plugin1
            config-2: