Skip to content
Latchkey

Bitbucket Deployment Environment Not Found

A step declared deployment: <name>, but no environment with that name exists in the repository’s deployment settings - so Bitbucket cannot map the step to an environment.

What this error means

The pipeline fails configuration or the deployment step errors that the named environment is not found or not configured. Deployment tracking and environment variables for that env never apply.

Bitbucket UI
Configuration error: deployment environment "staging" is not
configured for this repository.

Common causes

The environment name does not match settings

A deployment: staging step requires an environment named exactly staging in Repository settings → Deployments. A typo or a never-created environment fails to resolve.

Using a non-standard environment tier name

Bitbucket environments belong to tiers (test/staging/production). A custom name must still be created as an environment; the keyword alone does not define it.

How to fix it

Create the environment in settings

  1. Open Repository settings → Deployments.
  2. Add an environment whose name matches the deployment: value in your YAML.
  3. Add any environment-scoped variables there (e.g. deploy keys).

Reference the environment by its exact name

bitbucket-pipelines.yml
- step:
    name: Deploy to staging
    deployment: staging
    script: [ ./deploy.sh staging ]

How to prevent it

  • Create deployment environments before referencing them in YAML.
  • Keep deployment: names identical to the configured environment names.
  • Scope deployment variables to the environment, not globally.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →