Integrating Travis, SonarQube and GitHub

Travis CLI

In order to get the build going, the tokens need to be put into the .travis.yml. This is done using the travis command unless you want the tokens exposed in your source code. To install this, you need to have Ruby Gems installed so it’s a matter of running the following to install Travis CLI.

gem install travis

In case you get a SSL certificate problem, you can use the following commands to temporarily disable certificate checksĀ then update to get the latest certificates and restore the certificates afterwards.

gem source -r
gem source -a
gem update --system
gem source -r
gem source -a

Once you have the CLI installed run the following (substitute with the proper tokens from earlier steps)

travis encrypt <token from> --add addons.sonar.token
travis encrypt SONAR_GITHUB_TOKEN=<token from> --add

Finally, push your changes and Travis should start working and hook up with SonarQube look at the log to get the URL for SonarQube for your project. You can them do a push in a pull request to see it analyzed by SonarQube as well. Note that the token does not need the environment variable name prefix.