Skip to content
Latchkey

Bitbucket "stage" Grouping Invalid in a Pipeline

A stage groups related steps so they share a name and can gate deployment together. If the steps are not nested under the stage, or the stage is empty, Bitbucket rejects the structure.

What this error means

The pipeline fails configuration around a stage block - an empty stage, a step that should be inside it sitting outside, or a deployment stage that does not resolve to an environment.

Bitbucket UI
Configuration error: "stage" must contain at least one step.

Common causes

Stage declared with no steps

A stage: must contain a steps: list with at least one step. An empty stage, or one where the steps are misindented out of it, is invalid.

Deployment stage without a resolvable environment

A deployment stage carries a deployment: that must map to a configured environment. A missing or misnamed environment makes the stage fail to resolve.

How to fix it

Nest steps inside the stage

Place every step that belongs to the stage under its steps: list.

bitbucket-pipelines.yml
- stage:
    name: Deploy
    deployment: staging
    steps:
      - step: { script: [ ./build.sh ] }
      - step: { script: [ ./deploy.sh ] }

Ensure the deployment environment exists

  1. Confirm the deployment: value matches an environment in Repository settings → Deployments.
  2. Create the environment if it does not exist.
  3. Re-validate the stage structure before pushing.

How to prevent it

  • Keep at least one step under every stage.
  • Indent stage steps consistently so none fall outside the stage.
  • Create deployment environments before referencing them from a stage.

Frequently asked questions

What causes ""stage" grouping"?
A stage: must contain a steps: list with at least one step. An empty stage, or one where the steps are misindented out of it, is invalid.
How do I fix "stage" grouping?
Place every step that belongs to the stage under its steps: list.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card