Tag Archives: continuous integration

Cassandra on droid.io

droid.io is an other travis clone.

I gave it a try to execute some automated tests on top of cassandra. Unfortunately it doesn’t support cassandra out of the box. But adding support for it is in fact quite easy:

Here is a script to load cassandra and wait for its startup:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
 
curl -LO http://archive.apache.org/dist/cassandra/2.0.5/apache-cassandra-2.0.5-bin.tar.gz
tar xf apache-cassandra-2.0.5-bin.tar.gz
ln -s apache-cassandra-2.0.5 cassandra
cd cassandra
 
sudo mkdir -p /var/lib/cassandra /var/log/cassandra
sudo chown `whoami` /var/lib/cassandra /var/log/cassandra
 
bin/cassandra
 
for i in {0..30}; do echo "Waiting server ($i)..." ; nc localhost 9042 </dev/null && exit 0 ; sleep 1; done;
 
exit 1

Deploying your maven web apps on glassfish with jenkins

Simple deployment

If your jenkins server is installed on the same host as the glassfish server it’s quite simple.
You just have to let maven do its thing and then add this shell command:

1
/usr/local/glassfish/bin/asadmin --echo=true --host=localhost --port=4848 --user=admin --passwordfile=/secure/place/for/passwords/domain1_password --secure=false deploy --force=true --name=myproject --contextroot=/myproject target/*.war

The /secure/place/for/passwords/domain1_password should contain this:

1
AS_ADMIN_PASSWORD=the_password

Deploying different versions

With parametrized build you can go a little further and decide, for instance, if you want to deploy the current version as the production one or not. You can switch the build as a parametrized one and add a “stable” parameter (with a default value of false) for example.

The the only thing you have to do is to switch the previous code to:

1
2
3
4
5
if $stable; then
    /usr/local/glassfish/bin/asadmin --echo=true --host=localhost --port=4848 --user=admin --passwordfile=/secure/place/for/passwords/domain1_password --secure=false deploy --force=true --name=myproject --contextroot=/myproject target/*.war
else
    /usr/local/glassfish/bin/asadmin --echo=true --host=localhost --port=4848 --user=admin --passwordfile=/secure/place/for/passwords/domain1_password --secure=false deploy --force=true --name=myproject-test --contextroot=/myproject-test target/*.war
fi

Using the jabber plugin

Then you can use the jabber plugin and you will have interesting conversations with your jenkins build system, like:
!build myproject

And when you feel you are ready to go live:
!build myproject stable=true

Notes

  • It’s even simpler with other servers like tomcat or jetty.
  • Glassfish is often considered as very heavy but as most of the OSGi based softwares, you can remove a lot of its parts and make it as light as tomcat.