Deploy to Heroku

Deploying your application to Heroku from Bitbucket Pipelines.

See also Test with databases in Bitbucket Pipelines.

Step 1: Add your Heroku API token and app name as an environment variables

Define two environment variable in your Pipelines settings for your Heroku repository:

名前
HEROKU_API_KEY API token generated from Heroku. Use a secured variable for this so that it is masked and encrypted
HEROKU_APP_NAME Heroku app name

You can define this environment variable at either the repository or team level. The example below is shown with a repository environment variable.

Step 2: Configure your Pipeline to do a full clone

Heroku deployments require a full Git clone. By default, Pipelines clones your repository with a depth of 50 to shorten your build time. You can configure your Pipeline to do a full Git clone in your bitbucket-pipelines.yml file.

Step 3: Push your repository to Heroku

Deploy your application to Heroku by pushing it to Heroku's Git remote with the API key and app name defined in Step 1.

Below is a simple bitbucket-pipelines.yml configuration that deploys an application to Heroku

bitbucket-pipelines.yml
image: node:6
clone:
  depth: full
pipelines:
  default:
    - step:
        script:
          - npm install
          - npm test
          - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

For custom pipelines, you should create a branch before pushing as running a custom pipeline for a commit will run it in detached HEAD.

You can check your bitbucket-pipelines.yml file with our online validator.

最終更新日 2017 年 8 月 2 日

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

お探しの情報が見つかりませんか?

コミュニティへの質問

Powered by Confluence and Scroll Viewport.