Integrate Github Repo with Travis CI For Scala Play2.0 and MongoDB Project


Travis CI is a hosted, distributed  continuous integration service used to build and test projects hosted at  GitHub for the open source community.

It supports building software in numerous languages, including Ruby, JavaScript, Java, Scala, PHP, Haskell and Erlang.

A Travis worker comes with a good amount of services you might depend on, including MySQL, PostgreSQL, MongoDB, Redis, CouchDB, RabbitMQ, memcached and others.

Hosting your project on travis-ci.org means you can effortlessly test your library or applications against multiple runtimes and data stores without even having all of them installed locally.

Steps to integrate with Travis CI :

Step #1 : Sign in Travis CI with GitHub Account

To get started with Travis CI, sign in through your GitHub Account in https://travis-ci.org/.

Then GitHub will ask you for granting read- and write access.

Step #2 : Activate GitHub Service Hook

After Signed in Travis CI you need to activate GitHub Service Hook. For this you have to go  to your profile page in Travis CI where you find the list of your all GitHub’s repositories.Flip the on/off switch for each repository that you want to hook up on Travis CI.

To confirm that Travis CI activated for your repo(s)  , go to settings of your repo on GitHub

Settings -> Service Hooks ->Available Service Hooks  here you find that Travis option  in the list is activated.

When you click on Travis you find that GitHub user-name and Travis token into the settings for the Travis service is  already pre-filled.

Selection_008

Step #3: Add .travis.yml file 

In order for Travis to build your project , add .travis.yml to the root of your repository.

.travis.yml example for Scala , Play 2.0 and MongoDB Project

language: scala
scala:
- 2.9.2
- 2.9.1
jdk:
- openjdk7
- oraclejdk7

services:
- mongodb
- memcache

env:
- PLAY_VERSION=2.0.2

before_script:
- wget http://download.playframework.org/releases/play-${PLAY_VERSION}.zip
- unzip -q play-${PLAY_VERSION}.zip
script:
-  sbt test

notifications:
email: false

Step #4: Make a Git Push Request for trigger your first build on Travis CI

Once GitHub hook is set up, push your commit that adds .travis.yml to your repository. That should add a build into one of the queues on Travis CI and your build will start as soon as one worker for your language is available.

git commit -a -m "Add Travis CI"
git push origin master

Step #5 : Add Status image To README.md

To add a status image  copy the Markdown from  https://travis-ci.org/YOUR_REPO_NAME and paste into your README.md File. For Example :

Selection_010

When you click on it you would redirect to your Travis CI Build Detail Page .

By following the above mentioned steps you can integrate your GitHub Repo with Travis CI.

For More details refer to following link :  Travis CI Started Guide

For Reference To  Scalajobz   .travis.yml File : https://github.com/knoldus/scalajobz/blob/master/.travis.yml

knoldus/scalajobz  Travis CI Build Configuration  : https://travis-ci.org/knoldus/scalajobz

About these ads

About ruchijindal

Software Engineer in Knoldus
This entry was posted in Scala and tagged , , , , , . Bookmark the permalink.

One Response to Integrate Github Repo with Travis CI For Scala Play2.0 and MongoDB Project

  1. Great stuff thanks, you made my day I set that up in seconds because of this post.
    One thing though for play 2.2.1 the download address is now : http://downloads.typesafe.com/play/${PLAY_VERSION}/play-${PLAY_VERSION}.zip

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s