Conditional trigger skip if previous step failed

I want to trigger another pipeline at the end of the main CI build. However, I want to trigger it to only run or skip based on the previous step build status?

Hey @Joe looks like you need something like this: buildkite-agent step v3 | Buildkite Documentation

If you combine that with a dynamic pipeline upload and possibly with Managing Step Dependencies | Buildkite Documentation you should have everything you need to achieve such a pipeline structure.

The skip below the trigger command, how to make it conditional?

#!/bin/bash

set -euo pipefail

result="$(buildkite-agent step get outcome --step filter1)"

buildkite-agent pipeline upload <<YAML
steps:
  - label: "The pr pipeline"
    trigger: "pr-pipeline"
    skip:  if [ $(buildkite-agent step get "outcome" --step "filter2") == "soft_failed" ]; then
        "skip"
      fi
    build:
      env:
        RESULT: "${result}"
YAML

Good question.

It depends if you still want it in the pipeline but marked as skipped. Otherwise you could just not upload it. The skip attribute only takes a boolean, and it can’t be evaluated like you’re example above.

I would do something like this and avoid the skip attribute entirely:

if [ $(buildkite-agent step get "outcome" --step "one") == "soft_failed" ]; then
  buildkite-agent pipeline upload ...
fi

This would only upload the step if you want to run it, and not upload it if you don’t. Otherwise, you could do something similar to set the skip attribute true/false.