Soft fail

The soft_fail attribute of a command step allows a step to exit with a non-zero status without failing the build. The step is marked as passed, and the build continues as normal.

pipeline.yml
steps:
  - label: "Smoke tests"
    command: "smoke-test.sh"
    soft_fail: true

Soft fail attributes

The soft_fail attribute has the following optional attributes:

exit_status The exit status number that triggers a soft fail. Accepts a single integer or "*" (wildcard) to match any non-zero exit status.
Example: 1
Example: "*"

Allow all non-zero exit statuses

Set soft_fail: true to allow any non-zero exit status to pass without failing the build:

pipeline.yml
steps:
  - label: "Lint"
    command: "lint.sh"
    soft_fail: true

Allow specific exit statuses

Pass an array of exit_status values to only soft fail on particular exit codes.

In this example, the Tests step soft fails on an exit code of 1, whereas the Multiple exit statuses step soft fails on either 1 or 42:

pipeline.yml
steps:
  - label: "Tests"
    command: "tests.sh"
    soft_fail:
      - exit_status: 1

  - label: "Multiple exit statuses"
    command: "other-tests.sh"
    soft_fail:
      - exit_status: 1
      - exit_status: 42

Use exit_status: "*" to match any non-zero exit status, which in this example, allows Tests to soft fail on any exit status:

pipeline.yml
steps:
  - label: "Tests"
    command: "tests.sh"
    soft_fail:
      - exit_status: "*"

Soft fail and dependencies

Setting soft_fail on a step also allows steps that depend on it to run, even when allow_dependency_failure: false is set on the subsequent step.

In the following example, step-b runs because step-a is soft failing. If step-a were to fail with a different exit code, step-b would not run.

pipeline.yml
steps:
  - key: "step-a"
    command: echo "soft fail" && exit 42
    soft_fail:
      - exit_status: 42

  - key: "step-b"
    command: echo "Running"
    depends_on: "step-a"

Soft fail in a build matrix

You can use soft_fail within a build matrix adjustments block to soft fail specific matrix combinations:

pipeline.yml
steps:
  - label: "Tests"
    command: "tests.sh"
    matrix:
      setup:
        os: ["linux", "windows"]
        arch: ["amd64", "arm64"]
    adjustments:
      - with:
          os: "windows"
          arch: "arm64"
        soft_fail: true

See also Matrix adjustments on the Command step page for more information.