Deploy to Heroku
Deploying your application to Heroku from 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:
||API token generated from Heroku. Use a secured variable for this so that it is masked and encrypted|
||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 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: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.