Why does Bitbucket Pipelines pass build steps despite previous command failure?

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

This knowledge-based article discusses the scenario wherein Bitbucket cloud pipelines pass the build even though the previous command failed.

Cause

Consider a pipeline using a step with a script as below:

1 2 3 script: - false && true - false && true

The Bitbucket pipeline execution environment would convert this into a script as below:

1 2 3 4 5 6 7 8 #!/bin/bash set -e printf "\x1d+ false && true\n" false && true printf "\n" printf "\x1d+ false && true\n" false && true printf "\n"

The behaviour of set -e causing an early exit is ignored in && commands unless the very last command of the && chain fails. This standard is also specified in the POSIX Shell Command Language specifications.

The -e setting shall be ignored when executing the compound list following the while, until, if, or elif reserved word, a pipeline beginning with the ! reserved word, or any command of an AND-OR list other than the last.

Solution

To avoid the early determination of the results, the commands can be split into multiple commands without using `&&`.

If you are encountering issues following this documentation - please raise a support ticket or a community support ticket for further assistance.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.