Java — Git — TravisCI — Heroku Integration
Prerequisites#
- Your Java Maven Application on Github.
- TravisCI Account.
- Heroku Account.
Step-1: I know that you are a Java Ninja so you know how to check-In your code on GitHub. So I am moving to the step-2.
In case If you want to get start with GitHub then see Hello GitHub
Step-2: Creating Travis CI Account
To get started with Travis CI #
- Go to Travis-ci.com and Sign up with GitHub.
- Accept the Authorization of Travis CI. You’ll be redirected to GitHub.
- Click the green Activate button, and select the repositories you want to use with Travis CI.
- Add a
.travis.ymlfile to your repository parallel to the pom.xml to tell Travis CI what to do.
Step-2: Creating Heroku Account
Sign Up for a Heroku Account
To deploy an app on Heroku, you need an account on the platform. It’s quick and easy (and totally free) to sign up. Go ahead and do that now at signup.heroku.com. We’ll wait here.
After you’re logged in to your shiny new Heroku account, you’ll find yourself at the dashboard. It says, “Getting Started with Heroku”. If you’re new to Heroku, select one of the icons that represent your programming language and follow the Getting Started guide to create a new app.
But Heroku offers a way for you to get started even quicker by using a tool called Buttons. With just the click of a button, you can deploy a preconfigured app that has everything it needs, including code, configurations, and add-ons. By creating your first Heroku app with a button, you get a flavor for how easy the platform is to use. You also get a real, functioning Node.js app that you can explore and modify to learn more.
Install your first app by clicking this button:

- Enter a name for your new app, or let Heroku choose one for you.
- Select in which region to create your runtime: United States or Europe.
- Click Create App to deploy the application. Within a minute or two your app will be up and running on Heroku!

Click Open App to see your app in action, running live on the web.

Hello World! Congratulations, you’ve just deployed your first app to Heroku. How easy was that?
Great!!!Now you are ready with your first app on Heroku Server and an app working fine.
Let’s modify the .travis.yml for our java applocation and Deploy it to the app we created on Heroku.
language: java
jdk:
- oraclejdk8
deploy:
provider: heroku
api-key:
secure: "<HEROKU_API_KEY>"
app: <YOUR_HERKU_APP_NAME>before_install:
- chmod +x mvnw
<HEROKU_API_KEY>: you can see the api Key in you account Settings in Heroku Account.

Now do some changes in your code and check-In to the GitHub Repository. Don’t forget to check-In the .travis.yml.
You can see you code building on travis-ci.org in your account on your activated repository in STEP-2. Check the build logs and if everything goes fine then you will see your app deployed on Heroku at following URL.
www.<your_app_name>.heroku.com
You Liked this Article? Let’s give a (big) round of applause by clicking the clapping icon below and Don’t forget to follow to grab the latest trends in technology.
Thanks, please leave a comment if you are facing any issue.

