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
Different ways to deploy on Heroku
- using Heroku CLI
- Github auto deploy.
- Container registry configuration (In simple word by docker )
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
- 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.
- But wait, it will not happen automatically, we need to manually deploy it using Heroku CLI.
- for that, we need to use bash and push it. (a problem it is yeah !! ).
- 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.
- First, you need to create a pipeline of the repository, refer below picture.
- Under pipeline, Do below steps
- First select Java (maven)
- Now you need to add 2 Environment Variable[table id=1 /]
- 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 !!!