Do you, like me, think that no home is complete without a CI server and a deployment pipeline, but don’t want to have another computer running 24/7? I guess so. Well there is a solution for this problem: run it all on a Raspberry Pi. I just have to test the concept and added a 250 G hard disk to the Pi to make space for everything. The Linux OS is completely new to me so this is not an installation guide. Almost every command have been issued twice, first without sudo and then with sudo.
I started by installing Java. There are several guides on the web and by picking a hint here and a trick there I manage to execute the magic java –version command to get:
java version "1.7.0_40" Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)
I guess it become a bit messy because I persist on keeping Java (and the other packages) on the hard disk and I have to set up numerous links.
So with Java on board it was time for the application server. Installing Tomcat 7 was fairly easy but it needed some more links to keep the installation on the hard disk. After installing the Tomcat admin module it was time to fire up the browser to verify the installation. Success!
sudo apt-get install tomcat7 sudo apt-get install tomcat7-admin
Don’t forget to adjust the PermSize. Jenkins will run out of memory with standard setting. As stated in /usr/share/tomcat7/bin/catalina.sh don’t change that file. Instead create or edit /var/lib/tomcat7/bin/setenv.sh
Set JAVA_OPTS=”-XX:PermSize=128m -XX:MaxPermSize=128m” and restart tomcat.
sudo service tomcat7 restart tail -f /var/log/tomcat7/catalina.out
What else does a CI server need? A repository manager of course! So download the Sonar Nexus war file and deploy it to the server by copy the war file to /var/lib/tomcat7/webapps . Now the speed of Pi, or lack thereof, becomes clear. I take forever to start the Nexus application, but after about 30 minutes (yes minutes) it appears. Initially my intention was to use the repository as a proxy for everything but it will only be used as a local central repository for my own deployments.
After installing Maven it was time to configure the project pom file. I struggled for a while with the settings. I found most of the Maven documentation confusing until I found this page Configure Maven to Deploy to Nexus . It was actually that simple!
Add this to the pom file:
<distributionManagement> <repository> <id>deployment</id> <name>Internal Releases</name> <url>http://pici:8080/nexus-2.7.0-06/content/repositories/releases/</url> </repository> <snapshotRepository> <id>deployment</id> <name>Internal Releases</name> <url>http://pici:8080/nexus-2.7.0-06/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
This have to be added to Tomcat’s settings.xml
<servers> <server> <id>deployment</id> <username>deployment</username> <password>deployment123</password> </server> </servers>
The important part is that the id tag shall be the same in both files
With Maven and Nexus in place it was time for a gently ‘mvn clean’. It works! Let’s try mvn clean deploy.
Uploading: http://pici:8080/nexus-2.7.0-06/.....snapshots/se/minidev/savings/Savings/3.1-SNAPSHOT/Savings-3.1-20140115.224942-3.war Uploaded: http://pici:8080/nexus-2.7.0-06/.....snapshots/se/minidev/savings/Savings/3.1-SNAPSHOT/Savings-3.1-20140115.224942-3.war (14887 KB at 809.3 KB/sec) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
YES module safely stored in the repository!
Time for Mr. Jenkins. Just download the war file from jenkins-ci.org and drop it in the webapps folder. Restart server, wait half an hour for Nexus start up and then call Jenkins at http://pici:8080/jenkins/
Set up the first job is quite simple and after a while it’s all up and running. I got a strange errors when i have a space in the job name. Jenkins failed to write to the /target folder.
Now when everything run, slow but lean, I just have to set up more jobs for release-builds and deployment to my JBoss AS running on my Widows 2008 server. The deployment pipeline will be the next project but I have to read up on that a bit more.
Setting up the Pi was an interesting experience, very different from my previous work on Windows servers, but newer the less very interesting. If it’s possible to run a CI / deployment pipeline on about 10W it’s really nice. But the next setup will use a 32G high speed SD card instead of an external hard disk. Eventually Nexus and Jenkins should run on separate Raspberry’s.
Great thank’s to Mattias Nyrén and Johan Rydström from Diversify for their DEV + OPS = Fun! presentation, at the Diversify Competence Conference in Barcelona last year, that inspired me to try this.