🚀 Setting Default Agents for a Build


#1

Now that we can define our steps using YAML directly in Buildkite, we’re able to offer a bunch of new features that we couldn’t before. One of those new features, is being able to define a top level agent block on a pipeline:

agents:
  queue: "elastic-runners"

steps:
  - command: "test.sh"
  - command: "lint.sh"
  - wait
  - command: "deploy.sh"
    agents:
      queue: "deploy"

In this pipeline, the first 2 commands will run on agents with the queue=elastic-runners tag, where as the last one will run on queue=deploy since its’ overridden the default queue.

You can think of the top level agents block as being “default agents for the entire pipeline”. This means future steps that are created (via buildkite-agent pipeline upload will also use these default agents). If you upload a pipeline with a top level agents block defined, those values will become the new defaults.

Environment variable interpolation works great here as well:

agents:
  queue: "${FORCE_QUEUE-elastic-runners}"

steps:
  - command: "test.sh"

Here the the default queue for test.sh will be elastic-runners - unless specifically overridden using the FORCE_QUEUE environment variable (which can be defined by either using the “New Build” dialog or via the API).

There’s more information about environment variable interpolation in our docs: https://buildkite.com/docs/agent/v3/cli-pipeline#environment-variable-substitution and what expansions we support are here: https://github.com/buildkite/interpolate


Verifying the integrity of third party plugins
#2

Awesome! Will this feature also work for pipeline.yml from a repository? Didn’t seem to with a quick play :(


#3

Good question! I’ve wrapped the default agents functionality behind the “is the pipeline using the new YAML steps” feature. If you’ve toggled on the YAML steps for a pipeline, it should work.

If it doesn’t, then that’s a bug! (if that’s the case, and you paste your example so I can have a look locally?)


#4

I wasn’t using that, but was expecting it still to work from a pipeline.yml, e.g.

Buildkite UI:

buildkite-agent pipeline upload

pipeline.yml:

agents:
    queue: my-queue
steps:
    - command: echo hello

or have I misunderstood? E.g. this only works with YAML steps in the UI?


#5

Yeah, that’s the way it’s designed I’m afraid. I’ll see if I can back port it into the older gear as well…

I’ll let you know how I go!