Wait Step

A wait step waits for all previous steps to have successfully completed before allowing following jobs to continue.

Screenshot of a basic wait step

A basic wait step can be defined in your pipeline settings, or in your pipeline.yml file. It can be placed between steps to ensure that previous steps are successful before continuing to run the rest.

- command: "command.sh"
- wait
- command: "echo The command passed"

Continuing on failure

You can also configure the wait step to continue even if the previous steps failed. If steps failed, the build will be marked as failed only after any steps after the wait with continue_on_failure: true have completed.

This is useful for processing results from previous steps, for example, test coverage or summarizing test failures. Successful steps that run after a continue_on_failure step will not affect the status of the build; if there has been a failure, the build will be marked as failed.

In the example below, if command.sh succeeds, both of the following command steps will be run. If command.sh fails, only the first will be run, and the build will then be marked as failed.

- command: "command.sh"
- wait: ~
  continue_on_failure: true
- command: "echo This runs regardless of the success or failure"
- wait
- command: "echo The command passed"

If there's a failure followed by a regular wait step, nothing after the wait step will run, including any subsequent wait steps with continue_on_failure: true. In the example below, when the first command fails, the second and third commands will not run:

steps:
  - command: "exit -1"
  - wait
  - command: "echo SECOND command"
  - wait: ~
    continue_on_failure: true
  - command: "echo THIRD command"
Screenshot of a failed pipeline which didn't run the continue_on_failure wait steps

Any wait steps with continue_on_failure: true that aren't separated by regular wait steps will all run if a failure occurs. In the below example, after the first command fails, the second, third, and fourth commands will all run:

steps:
  - command: "exit -1"
  - wait: ~
    continue_on_failure: true
  - command: "echo SECOND command"
  - command: "echo THIRD command"
  - wait: ~
    continue_on_failure: true
  - command: "echo FOURTH command"
Screenshot of a failed pipeline which did run the continue_on_failure wait steps

The explicit null ~ character used in the above examples isn't required, but is reccommended as a best practice. It ensures that nothing else is accidentally added to the wait before the continue_on_failure attribute.