Setting up Jenkins with Lithium
After my blog post about how I set up Jenkins and Phing to build lithium apps I was asked if I could share my Jenkins set up. So I figured I might as well document the entire install. Easiest way to document the entire process is to start from fresh and document each step, so I fired up a ubuntu cloud server instance and here’s what I did to get Jenkins to successfully build my lithium app.
Step one install Jenkins, mercurial and MySQL. Jenkins to for obvious reasons. MySQL since my lithium application requires MySQL database usage. During this it’ll ask me to set my root password for MySQL. Since this is a temporary instance that won’t be about for more than an hour or so I’ve just used root. With mercurial being the version control system being used to store the code.
root@Jenkins# apt-get install mysql-server jenkins mercurial
Step two is to install php and pear. Easy enough.
root@Jenkins# apt-get install php5 php-pear php5-mysql
Step three install phing
root@Jenkins# pear channel-discover pear.phing.info root@Jenkins# pear install [--alldeps] phing/phing
Step four set up the database. Since I’m using MySQL in my app I have to create the database and the table structure. I’ve whacked all the SQL to do this in a SQL file.
root@Jenkins:~# mysql -u root -p < structure.sql
Step five configure Jenkins, to do that I just have to access the server on the port 8080 which is the default port for Jenkins.
Step six manage Jenkins, I need to install some plugins for my build since I’m using phing and mercuical.
Step seven select the phing plugin.
Step eight select mecurial plugin
Step nine install the plugins.
Step eleven wait for Jenkins to restart, this will take a minute or so.
Step twelve create a new job. I’ve just gone for the free style software project since my build is currently rather simple.
Step thirteen enter the mercurial details. I’ve blanked them out for obvious reasons. Then I needed to create a build step from the drop down and select phing and put “main” in the target input field. (I forgot to take a screenshot of this)
Step fourteen run a build, this will do the mercurial cloning for me. It fails the first time, because I’ve not included the connections.php file in mercurial due to everyone having different settings and it’s a pain when someone changes it and it breaks a bunch of peoples dev environments. (yes I know about the enviroment ability, it’s still just a pain)
Step fifthteen run another build after I’ve added the connections.php file. And see the successful build. (For some reason the circle image didn’t change to yellow/green like it should)
My current phing build file is extremely basic, since the project is in a very early stage it just runs the tests. Since Lithium has it’s own test framework I’ve created my own phing test tasks which can be found here on github. The build file I use can be found below.
This should be pretty much everything anyone should need to use Jenkins with Lithium. If anyone has any questions or better ways of doing things just leave a comment.