How to deploy on Heroku from bitbucket pipelines

Many of us know about the Heroku ( if not learn from here ) to deploy our project on the cloud for free. Heroku provide free services up to 500Mb for your code to be deployed.

Deployment on Heroku is way easy, let’s see the ways below

Deploy on heroku using bitbucket pipeline

Different ways to deploy on Heroku

  1. using Heroku CLI
  2. Github auto deploy.
  3. Container registry configuration (In simple word by docker )
  4. Connect with Dropbox  (Deprecated )

When we have these many deployments option, why would we need to continue this article, wait there is one problem we still need to address here.

The problem (there is no auto-deploy option for Bitbucket Repository )

We know that we have Github but it doesn’t provide a private repository for that we move to bitbucket, as it allows private repository for free accounts as well.

But there is no option of auto-deploy the code on Heroku using bitbucket repository.

Also Read: Top 5 Online Course for Spring Developers

Available Options

  1. Either we do to install Heroku CLI and every time we do changes we need to push the code to Heroku as well so that it can be deployed as well.
    1. But wait, it will not happen automatically, we need to manually deploy it using Heroku CLI.
    2. for that, we need to use bash and push it. (a problem it is yeah !! ).
  2. You have one option, Its using Bitbucket Pipelining to deploy the code to Heroku automatically.

What are pipelines: In computing, a pipeline, also known as a data pipeline, is a set of data processing elements connected in series, where the output of one element is the input of the next one. The elements of a pipeline are often executed in parallel or in a time-sliced fashion. (source- Wikipedia)

Now let’s talk about the Option 2  – Configuring BitBucket Pipeline.

By Bitbucket Pipeline We can auto-deploy code on Heroku, for that follow below steps.

  1. First, you need to create a pipeline of the repository, refer below picture.Bitbucket-pipelining-pic
  2. Under pipeline, Do below steps
    1. First select Java (maven)
    2. Now you need to add 2 Environment Variable[table id=1 /]
    3. Now you need to change the yml file as below
# This is a sample build configuration for Java (Maven).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: maven:3.3.9
clone:
  depth: full

pipelines:
  default:
    - step:
        caches:
          - maven
        script: # Modify the commands below to build your repository.
                   - mvn clean install     # IMPORTANT here you need to define all the sets for your code to be build             
                   - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD:master 

Once you configured the yml file, Once you commit this file, you will be able to deploy the code automatically by bitbucket.

I hope this will help you for deploying your code over Heroku.

If you face any issue while configuring the above, please leave us a comment, Will be happy to help you !!!

 

You may also like...

2 Responses

  1. wearer says:

    Hello just wanted tߋ give yoս a quick heаds up.

    The text in your article seem to be running off the screen in Ie.
    I’m not sure if this is a format issue or something to do ᴡith
    internet browser comρatibilitʏ but I figurеd I’d post to let you
    know. The layout look grеat though! Hope you get the problem fixed soon. Kսdos

  2. pdf says:

    En Güzel Kitaplar Yeni Yazılan Kitaplar

Leave a Reply

Your email address will not be published. Required fields are marked *