I am just trying to get my hands dirty on developing Spring Boot and deploy that to Free Dyno for Heroku.
I found that guide giving for bitbucket pipeline is for npm based system. Refer Deploy to Heroku. So here are the things that I tried for bitbucket pipeline to run Spring Boot with proper maven lifecycle which packages uber jar and then customise setting of pipeline which you can run on any commit for deployment on Heroku.
Note: If you are reading this post I assume that you are familiar with Spring Boot application and Heroku.
In order to use bitbucket pipeline we need an bitbucket-pipelines.yml
. So for Spring Boot application I used below settings for maven to run test on every push regardless of branches.
Note: Add bitbucket-pipelines.yml at root level of project.
image: maven:3.3.9
clone:
depth: full
pipelines:
default:
- step:
caches:
- maven
script:
- mvn clean test
Now in order to deploy our application to Heroku you need to make a custom settings in pipeline. Refer custom settings
For $HEROKU_APP_NAME
and $HEROKU_API_KEY
refer deploy to heroku.
custom:
deploy_to_heroku:
- step:
image: ruby:2.4.0
script:
- gem install dpl
- dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY
dpl
used inside the code block is a deployment provider by Travis CI which uses Ruby as base and also supports many providers. So image of ruby image: ruby:2.4.0
as has been added to execute the gem
script.
References
Using pipelines with Java: https://confluence.atlassian.com/bitbucket/java-with-bitbucket-pipelines-872013773.html
Deploy to Heroku: https://confluence.atlassian.com/bitbucket/deploy-to-heroku-872013667.html