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 variables in your settings for your Heroku repository:

Name Value
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 these variable at the deployment environment, 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

image: node:6
  depth: full
    - step:
          - npm install
          - npm test
          - git push https://heroku:$$HEROKU_APP_NAME.git HEAD:master

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.

Last modified on Nov 26, 2018

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.