Continuous Integration: Java Spring Boot project with Travis

Compile and test your code on every change you commit is a good start point to develop high quality software. Iterate over stable software, write good tests and fix the bugs. This is the way.

Continuous integration can help you in this path looking to minimize headaches and maximizing quality code.

Travis CI dashboard with branches with builds passings tests

In this example we’ll setup the minimal configuration of a Java Spring Boot with Maven and Travis CI. I’ll use a sample repository from my github: bank-api.

  1. Go to https://travis-ci.com/ and login with GitHub/GitLab account.

2. In your Git repository add the travis configuration file .travis.yml

Explanation of the file:

  • language: java
  • jdk: we’re using oraclejdk11
  • script: the command we want to run
  • before_install: the maven wrapper must be executed in the Travis environment, so we need to update the permissions before the script runs

3. Git commit and push the file to the repository.

Important: the Maven wrapper folder .mvn must be included in the repository (check if it’s excluded from .gitignore file).

4. We can go to the Travis CI dashboard and check the build execution results

My public Travis-CI https://travis-ci.com/github/miguelms95

Now you can add the Travis CI badge to the readme, isn’t it cool? :P

  • Click on the badge next to the project in https://www.travis-ci.com/
  • Select the branch, “Markdown” format, copy the result and paste on the Readme.md
Badge image markdown format
Travis build badge at Readme.md

Twitter: @miguelms_es

If you want to contact: miguel@miguelms.es

Software Engineer | University of Oviedo | Video post-production | Music production | Social Media

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store