Buildkite Pipelines

Buildkite is a tool for defining workflows in something called a “pipeline”, and you guessed it, you can define these pipelines with a YAML file! Again let’s borrow an example from their documentation and look at some YAML features within it:

steps:
  - label: ":hammer: Tests"
    command: scripts/tests.sh
    env:
      BUILDKITE_DOCKER_COMPOSE_CONTAINER: app

  - wait

  - label: ":package: Package"
    command: scripts/build-binaries.sh
    artifact_paths: "pkg/*"
    env:
      BUILDKITE_DOCKER_COMPOSE_CONTAINER: app

  - wait

  - label: ":debian: Publish"
    command: scripts/build-debian-packages.sh
    artifact_paths: "deb/**/*"
    branches: "master"
    agents:
      queue: "deploy"

  - block: ":shipit: Release"
    branches: "master"

  - label: ":github: Release"
    command: scripts/build-github-release.sh
    artifact_paths: "releases/**/*"
    branches: "master"

  - wait

  - label: ":whale: Update images"
    command: scripts/release-docker.sh
    branches: "master"
    agents:
      queue: "deploy"

At the top level we see the steps key mapping to a list. Each entry in this list is one step of our pipeline and they are executed in the order you define them in (first we run tests, then we package our app, then we release it and deploy). Buildkite defines different step types that each have a specific schema for you to fill out. The first step in this example is a command step; it requires you to define the command key as the shell command(s)/script(s) to run. You can either define a string scalar (as this example does with scripts/tests.sh or you can define a list of strings representing multiple commands. Note how any strings using the reserved characters : and * use double quotes. Several step types also let you define common keys like label, branches, agents, etc. that help control and better define how your pipeline functions.

Buildkite pipeline files are a great example of YAML’s readability. YAML syntax affords great alignment with the conceptual model of a pipeline; when you look through the example above it is extremely clear what is being represented. You can see that we have a list of ordered steps to perform and intuitive keys like label and command immediately let you know what those steps mean.

%d bloggers like this: