Bitbucket pipelines: Failing parallel builds fast

Parallel steps in Bitbucket Pipelines allow you to build and test faster by running a set of steps at the same time. However, if one of parallel steps fails, the rest of the build continues to run, consuming time and build minute costs.

Today, we are announcing a fail-fast option in Bitbucket Pipelines, which will immediately stop all running parallel steps as soon as any step fails.

Here's an example of how to use it:

pipelines:
  default:
    - step:
        name: Build
        script:
          - ./build.sh
    - parallel:
        # configure parallel steps 
        # to stop all running steps on failure
        fail-fast: true
        steps:
          - step:
              name: Integration 1
              script:
                - ./integration-tests.sh --batch 1
          - step:
              name: Integration 2
              script:
                - ./integration-tests.sh --batch 2
    - step:       
        script:
          - ./deploy.sh

In the example above, adding the fail-fast: true attribute to the parallel group will cause all running parallel steps to be stopped if any of the tests batch failed.

Also, fail-fast attribute can be defined just for some steps:

pipelines:
  default:
    - step:
        name: Build
        script:
          - ./build.sh
    - parallel:
        steps:
          - step:
              fail-fast: true
              name: Integration tests
              script:
                - ./integration-tests.sh
          - step:
              fail-fast: true
              name: Integration tests
              script:
                - ./integration-tests.sh
          # the step failure won't stop pipeline
          - step:
              name: Send build metrics
              script:
                - ./send-metrics.sh
    - step:      
        script:
          - ./deploy.sh

Additional documentation on using parallel steps here. We hope you and your team find this extra flexibility helpful! 

Happy coding!