Set up Bitbucket Deployments

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

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

ステップ 2: デプロイメント手順を構成する

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

例:

- 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 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.


bitbucket-pipelines.yml ファイルの例
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

ステップ 3: デプロイメントを追跡する

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

最終更新日 2019 年 6 月 4 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.