Skip to content
Latchkey

Bamboo "Failing task since return code was not 0" in CI

A command or script task exited with a non-zero return code. Bamboo treats any non-zero exit as a task failure and prints "Failing task since return code of the command was N and not 0". The real error is above this line.

What this error means

The task ends with "Failing task since return code of the command was N and not 0", where N is the exit code of the underlying command.

Bamboo
npm run build exited with 1
Failing task since return code of the command was 1 and not 0.

Common causes

The underlying command genuinely failed

The build, test, or lint command exited non-zero because of a real error, and Bamboo faithfully propagates that as a task failure.

A multi-line script where an early command fails

In an inline script, an early command exits non-zero; without careful handling the task return code reflects a failing step even if later lines run.

How to fix it

Read the command output above the failure line

  1. Scroll up from "Failing task since return code..." to the first real error printed by the command.
  2. Fix that root error (a failing test, a missing file, a compile error).
  3. Re-run the task once the command exits 0 locally.

Make script failures explicit

Use a strict shell so a failing early command stops the script clearly rather than masking the true failure point.

Script task
#!/bin/bash
set -euo pipefail
npm ci
npm run build

How to prevent it

  • Run the same command locally so non-zero exits surface before CI.
  • Use set -e in inline scripts so the first failure is the reported one.
  • Keep tasks small so a non-zero code maps to one clear cause.

Frequently asked questions

What causes ""return code ... was ... not 0""?
The build, test, or lint command exited non-zero because of a real error, and Bamboo faithfully propagates that as a task failure.
How do I fix "return code ... was ... not 0"?
Read the command output above the failure line

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card