Meta-data in conditional clause

Hi folks! After a deep discussion we’ve decided not to support meta-data in conditionals just yet, sorry! We want to do it well, and have an answer for what happens when meta-data changes over the lifecycle of a build, and we haven’t quite figured that out yet.

For now, you can do this with the buildkite-agent and a bit of scripting — and it’s not super different, like:

# buildkite.yml
steps:
  - block: "Request release"
    prompt: "Fill out the details for release"
    fields:
      - text: "Version"
        key: "version"
        hint: "Include the version according to the standard: 2.x.x.x"
        required: true
      - select: "Type"
        key: "release-type"
        default: "stable"
        options:
          - label: "Stable"
            value: "stable"
          - label: "Beta"
            value: "beta"
          - label: "Debug"
            value: "debug"
            
  - command: |
      if [[ "$$(buildkite-agent meta-data get release-type)" == "stable" ]]; then
        buildkite-agent pipeline upload buildkite-release-stable.yml
      fi

   # or even

  - command: buildkite-agent pipeline upload "buildkite-release-$$(buildkite-agent meta-data get release-type).yml"
# buildkite-release-stable.yml
steps:
  - trigger: stable
    label: ":rocket: Release a stable version"

We’ll make some noise when conditional support for meta-data changes.

1 Like