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_KEY for 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

Gif showing renaming, restricting, and adding an environment specific variable

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.

gif showing adding an environment

You can also move environments within their type by clicking the left hand edge and dragging:

gif showing clicking and dragging to reorder environments

Step 2: Configure your deployment steps

Add the deployment keyword, followed by the name of the environment, into the relevant step in your bitbucket-pipeline.yml file.

For example:

- step:
        name: Deploy to production
        deployment: production-east
          - python prod

This step will now show up in the the deployment dashboard.

We support deploying to teststaging, and 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.

Example bitbucket-pipelines.yml file
image: node:10.15.0

    - step:
        name: Build and push to S3
          - apt-get update
          - apt-get install -y python-dev
          - curl -O
          - python
          - 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
          - python test
    - step:
        name: Deploy to staging
        image: aneitayang/aws-cli:1.0
        deployment: staging1
        trigger: manual
          - python staging
    - step:
        name: Deploy to production
        image: aneitayang/aws-cli:1.0
        deployment: production-east
        trigger: manual
          - python prod

Step 3: Track your deployments

Once your deployment step has run, you can track your deployments on the Deployments dashboard.