Prev Next

Continuous Integration

What You Will Learn

In this section we will use [Github] and [Travis], free services for developers when open source, to setup a continuous integration system.

In this section it is assumed you’ve an account on Github and Travis.

Creating a Github Repository

So far we’ve created a repository but it is not yet a git repository and it is also not yet stored on Github.

First step is to create a repository on Github with the required name: osgi.enroute.examples.eval. Once you’ve created this repository, we need to add it in our workspace.

Committing the Repository

First we should set .gitignore to ignore any files we do not want to include. In general, the following should work:

osgi.enroute.examples.eval $ vi .gitignore
// add the following content
target/
generated/
*/bin/
*/bin_test/
*/target/
*/generated/
**/*.class
**/*.jar

We now need to connect the repository to Github (replace the xxxx with your user name):

osgi.enroute.examples.eval $ git init
osgi.enroute.examples.eval $ git add .
osgi.enroute.examples.eval $ git commit -m "first commit"
osgi.enroute.examples.eval $ git remote add origin git@github.com:xxxxxx/osgi.enroute.examples.eval.git
osgi.enroute.examples.eval $ git push -u origin master

Activating Travis

After we’ve created the Github repository we can enable it on the Travis site (replace xxxx with your Github user id).

You should click on your name in the right hand top corner and select Accounts. This opens a list of all your repositories. If you repository does not show up, you can push Sync Account. Flip the switch to on to activate your CI build.

Preparing for Travis

Travis is a free for open source continuous integration solution. By adding a simple file .travis.yml in the root of a Github repository we can build the workspace automatically.

osgi.enroute.examples.eval $ vi .travis.yml
// add the following content
language: java

jdk:
  - oraclejdk8

before_install:
  - rm ~/.m2/settings.xml

That is all! By default, Travis will call mvn install first without the tests and then later it will call mvn test to verify the results. Exactly what we need. This way we found any easy to find problems before we run long tests.

We remove the settings because the default settings contain repositories we do not want to use in our build.

So now save the change and commit it.

osgi.enroute.examples.eval $ git add .travis.yml
osgi.enroute.examples.eval $ git commit -m "Travis"
osgi.enroute.examples.eval $ git push

You can now go to the Travis site and watch our repo build:


Prev Next