These past weeks, while (eventually) working in my Stokker project, I noted the lack of continuous build that I usually enjoy at work. I committed many bugs to my code-base and even, non-compiling code!
So, what are the alternatives to fix this situation? Perhaps having a local Jenkins environment? Too hard to maintain. No CI at all? Not feasible if we pretend that somebody might cooperate in the future.
One possible solution: Use Github integration with Travis CI and Heroku
This is one of many and, to be fair, I did´t do a thorough study on the different choices before trying it. I noticed that JHipster is using it as CI system for part of its code-base, though.
Basically, what Travis-CI does is to poll regularly your repository and perform a build based on the parameters specified in a file called .travis.yml.
Here, we can see a very basic example on how does this file look like:
Basically, we are stating that:
- This is a Java project. As no build.gradle file has been provided, it will execute these Maven commands:
- mvn clean install
- mvn test
- We intend to deploy the result of the successful build to Heroku
- You can get the API Key later on, after registering in Heroku.
Hint on working with the .travis.yml file: One handy tool is this YAML validator, specially due to the cryptic error messages given by Travis-CI.
This is how a successful build looks like:
As said, once you have a successful build, Travis CI will trigger a Heroku deployment. By the way, what is Heroku? Heroku is a commercial PaaS that also offers some free functionality for hobby programmers and people learning. If you want to test it, follow this steps:
- Register in Heroku with your personal details.
- Create an application and link it with your Github:
- By doing so, you will be provided with an application key (which was inserted in the YML snippet above).
- Choose the "Free" dyno mode. This mode offers you very limited resources and the machine is shut down after 60 minutes of inactivity.
- By the way, these are the different plans available:
The way in which your application is executed, is defined in a Procfile (this file should be placed in the same folder of .travis.yml)
You can check the unfinished application running here:
Update on November 1st 2015: I had to separate Stokker and Portfolio Manager into two different Github repositories (and two Heroku applications) in order to be able to run both of them so the URL for the Portfolio manager in Heroku is now: https://stokker-portfolio-manager.herokuapp.com
- If prompted for authentications use "user" / "user" as login and password.
- You will notice that no price is used for the portfolios, as I still have not figured out how to run more that one application per repository.
- Kibana functionality won´t be available.
Manage your application with Heroku toolbelt
Heroku offers you a tool called Heroku toolbelt that you can install in your local computer and use it to:
- Manage and monitor your applications:
- You can login and check the application logs.
- You can deploy directly by performing a git push heroku.
- Deploy your applications in a local environment in order to ensure that everything is OK before pushing your code.
ResourcesThis is a really shallow introduction to Travis CI and Heroke. I am astonished, as the more I read the more documentation I found. Here you might find some interesting links in case you want to continue learning on this topic:
Hope that you find this quick introduction interesting, any feedback is always more than welcome! You can find the code of the unfinished application here.