Use the deployments dashboard to get information about all your deployment environments at a glance. Also you can use deployment variables with permissions to make sure only the branches or people you want to deploy, can.
First, we'll define your environments in Bitbucket settings.
You can set:
- their name
- what type of environment they are
- the order they show on your dashboard
- any variables specific to that environment
- and, if you have the premium plan, who can deploy to each one.
Then all you need to do is reference them in your
bitbucket-pipelines.yml file to see them on your deployments dashboard.
This guide covers the general setup of deployment environments, but then you might also want to look at our deployment guides for platform specific guidance.
Step 1: Define your environments
First we'll add the details of your environments.
When you enable pipelines, we create 3 basic environments for you by default, a test environment called 'Test', a staging environment called 'Staging', and a production environment called (you've guessed it!) 'Production'.
The environment types are used to logically order your environments, nothing more, so don't worry if the types don't quite match up to the function you use them for.
- Go into your repository settings ( )
- In the Pipelines section, choose Deployments
- Click on any environment to:
- change it's name
set environment specific deployment variables
Deployment variables override both team and repository variables. Also variables with the same name can have different values for each deployment environment. For example, you could set a different
$DEPLOYMENT_SECRET_KEYfor each environment. If you then also restrict the environment, only your admins can use your secret keys.
- restrict the ability to deploy to admins, or to specific branches
If you want to add more environments, decide which type of environment best describes it (test, staging, or production) and click add environment in that section.
You can also move environments within their type by clicking the left hand edge and dragging:
Step 2: Configure your deployment steps
deployment keyword, followed by the name of the environment, into the relevant step in your
- step: name: Deploy to production deployment: production-east script: - python deployscript.py prod
This step will now show up in the the deployment dashboard.
We support deploying to
production type environments, and they must be listed in this order in each pipeline. For example, if you have 2 test and 2 production environments, the steps deploying to any test environment must come before any step deploying to production type environments.
Commit the update to your
bitbucket-pipeline.yml file to run your deployment pipeline.
image: node:10.15.0 pipelines: default: - step: name: Build and push to S3 script: - apt-get update - apt-get install -y python-dev - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py - pip install awscli - aws deploy push --application-name $APPLICATION_NAME --s3-location s3://$S3_BUCKET/test_app_$BITBUCKET_BUILD_NUMBER --ignore-hidden-files - step: name: Deploy to test image: aneitayang/aws-cli:1.0 deployment: testbed script: - python deploy.py test - step: name: Deploy to staging image: aneitayang/aws-cli:1.0 deployment: staging1 trigger: manual script: - python deploy.py staging - step: name: Deploy to production image: aneitayang/aws-cli:1.0 deployment: production-east trigger: manual script: - python deploy.py prod
Step 3: Track your deployments
Once your deployment step has run, you can track your deployments on the Deployments dashboard.