Part 1: Continuous Integration (CI) with Jenkins for a application using Play Framework
Intro
A few months ago I have found Play Framework and I started using it to develop a web project. Before using play I was used with Struts, Spring MVC or other web frameworks and also I was using maven to build and pack my applications.In a large scale project it is a need to have CI configured and automatic deployment. The CI server I use is the open source server Jenkins. If you don't have Jenkins installed and configured check this link for help.
Install play framework
You need to download Play unzip and add the play location into path. If you know how to add a folder to the path then skip the next lines and check how to install the play plugin for Jenkins.I did the configuration as root:
- Unzip play:
unzip play-1.2.4.zip /destination - Create symbolic link to play(This will help us at version upgrades):
ln -s /destination/play-1.2.4 /destination/play - Add play to path:
vi /etc/profile
The command above will open the profile file for edit.
Add the following at the end of the file:
PLAY_PATH=/destination/play
export PLAY_PATH
PATH=$PATH:$PLAY_PATH
export PATH
- Logout so the paths are updated.
Install Play plugin for Jenkins
Got to Manage Jenkins -> Manage Plugins - > Available Plugin, check on playframework-plugin and install. Restart webserver or Jenkins server (depending if Jenkins is deployed in a webserver or is started as a service). Or you can install it manually by downloading the Jenkins Play plugin.Configure Jenkins job
Ok, we have installed Play! Framework and configured in path, we’ve installed the Play Plugin for Jenkins, let’s see how we create a Jenkins job for a play project in a few easy steps:- Click on ‘New Job’ in Jenkins dashboard.
- Configure the Play! Application path.
Jenkins checks out the code from a repository into a working directory. Usually the working directory will be /root/.jenkins/jobs/MyPlayProject/workspace but I have changed the location because when trying to zip the play module using the play build-module command, for some reason when creating a zip file in a hidden directory nothing is written in it. So because of the above motives I have changed the Job working directory to /jenkinsjobs/MyPlayProject/workspace.
In the workspace folder you will have:
workspace
api
my-play-project
Check Play! Application path and fill in the path field wih ‘my-play-project’. - Configure source code management GIT/SVN.
- Configure Build. From dropdown ‘Add build Step’ choose Play.
- Configure play commands:
I usually add the following commands when building my play modules:
deps --sync --clearcache
auto-test
build-module
Check this cheat sheet to test other play commands. - save and you are done.
Coming next...
Next I'll show you how you can configure code analysis with Sonar, how to upload your modules to a Nexus and create a dependency chain for your projects.Check Part 2: Continuous Integration (CI) with Jenkins for a application using Play Framework.
great post, looking forward for more... BTW, in this excellent book there's also a chapter on jenkins and play http://www.packtpub.com/play-framework-cookbook/book
ReplyDeletecheck part 2 of this article :)
Delete