How to Use Deployment Environments in Bitbucket Pipelines
The deployment: key tags a step with an environment so Bitbucket tracks what shipped where on the Deployments dashboard.
Mark a deploy step with deployment: staging or deployment: production. Bitbucket records the deployment and can scope environment-specific variables to it.
A tracked production deploy
Tagging the step with deployment: production surfaces it on the Deployments view.
bitbucket-pipelines.yml
pipelines:
branches:
main:
- step:
name: Deploy to production
deployment: production
script:
- ./deploy.sh productionGotchas
- Bitbucket has three built-in environment tiers (test, staging, production); names must map to these.
- Deployment variables defined on an environment are injected only into steps tagged with that environment.
- You can require admin approval on an environment to gate production deploys.
Related guides
How to Use Repository and Deployment Variables in Bitbucket PipelinesConfigure secrets and config in Bitbucket Pipelines with repository, workspace, and deployment variables - wh…
How to Create Custom (Manual) Pipelines in Bitbucket PipelinesAdd on-demand pipelines in Bitbucket with the custom key - manual triggers from the UI, plus variables that p…