Java Open Source XChart Library

XChart features a dead-simple API for turning your data into beautiful charts including line, scatter, area, pie, donut, bubble, stick, bar, and histogram charts. Extra features include: real-time, themes, CSV import and export, export as PNG, JPG, BMP, GIF, SVG, EPS and PDF and much much more. For full description and examples visit the project on Github!

In order to deal with the amount of different projects Knowm Inc. is currently managing, both open source and commercial, we jumped at the opportunity to move all of our OSS projects over from an in-house Jenkins CI to a free hosted Travis CI service. Doing so frees us up from having to maintain our Jenkins server, deal with it hanging, updating it, etc. This is just one more step in streamlining project development and management. The only disadvantage by doing this was the loss of our Sonar code quality analytics, but I suspect something of the sort will soon become available as a plugin to Travis CI.

What we needed Travis CI to do though was a bit non-standard, and we wanted to write what we learned here for future reference, but also to help other get their Maven builds deploying snapshots to a repository. This article assumes you’ve already setup your Travis CI account and have followed the standard setup procedures and configurations linking your Travis CI and GitHub accounts and projects. Make sure to enable the Travis CI hook in GitHub too. The example configurations contain stuff relevant to our project XChart, and you’ll have to adapt your configurations to your specific project’s properties.

Setup Travis Command Line Tool

Generate Encrypted Variables

The artifact repo requires a username and password of course, and we don’t want to have those as plain-text in the above settings.xml file. Therefore we use the following commands to generate the encrypted keys. Obviously replace timmolter/XChart with your own Github account name and project name. The username and password correspond to the login info you created during Sonatype’s Nexus repository system.

Shell

1

2

travis encrypt-rtimmolter/XChart"CI_DEPLOY_USERNAME=username"

travis encrypt-rtimmolter/XChart"CI_DEPLOY_PASSWORD=password"

.travis.yml

Place a file called .travis.yml in the root of the project on the branch you want to be deployed. You’ll need to modify this .travis.yml file as shown here. The whitelist specifies that we only want the build to run on the develop branch. Replace the keys below with your generated codes from the previous step. Note that the script line prevents snapshots being deployed when an update on the develop branch is due to a pull request. To prevent a snapshot deploy on a pull request the script checks the Travis environment variable TRAVIS_PULL_REQUEST and if it is a pull request, it runs mvn clean verify. Otherwise, it runs mvn clean deploy as we want.

Test It

Now that everything is setup, all you need to do is push a change on the develop branch to GitHub, and Travis CI will build the Maven project and deploy the artifacts to a snapshot repo automatically!

Other Travis CI Tidbits

Pushes that have [ci skip] anywhere in one of the commit messages will be ignored.

EDIT – this issue has now been fixed. You may need to place a .travis.yml file in all your project’s branches to prevent it to try to build those branches – even if your whitelist doesn’t include those branches. They are planning on changing this behavior though.