How to Use Deployment Environments in Bitbucket Pipelines
The deployment keyword on a step links it to an environment so Bitbucket tracks release history.
Tag a deploy step with deployment: production. Bitbucket records it in the Deployments view and injects environment-scoped variables.
Tag a step with an environment
The deployment keyword links the step to the production environment.
bitbucket-pipelines.yml
pipelines:
branches:
main:
- step:
name: Deploy
deployment: production
script:
- ./deploy.sh --token "${DEPLOY_TOKEN}"Notes
- Define environments (test, staging, production) in Repository settings > Deployments.
- Variables scoped to an environment override repository variables when that environment runs.
- Configure deployment permissions and gates on the environment to control who can promote.
Related guides
How to Deploy with Pipes in Bitbucket PipelinesDeploy from Bitbucket Pipelines using a pipe, a prepackaged integration that wraps a deploy action behind a f…
How to Build and Push to a Registry in Bitbucket PipelinesBuild a Docker image in Bitbucket Pipelines and push it to a registry, enabling the docker service so the bui…