Friday, March 12, 2010

Continuous Integration Server: Hudson for qt c++ project

What is Hudson?
Hudson monitors executions of repeated jobs, such as building a software project or jobs run by cron. Among those things, current Hudson focuses on the following two jobs:

  1. Building/testing software projects continuously, just like CruiseControl or DamageControl. In a nutshell, Hudson provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases the productivity.
  2. Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs, even those that are run on a remote machine. For example, with cron, all you receive is regular e-mails that capture the output, and it is up to you to look at them diligently and notice when it broke. Hudson keeps those outputs and makes it easy for you to notice when something is wrong.
Install Hudson
Install Hudson for testing is really simple, just download it an start the server:

wget http://hudson-ci.org/latest/hudson.war
java -jar hudson.war -httpPort=9000 &

Open http://localhost:9000 with your browser

Hudson and Git
Hudson has an extensive support for Source Code Management provided through plugin.
Go to manage plugin and install the git plugin.

Now when you create a new job you can set your git repository and select which branch to build:



Build Step
The last thing to do is build you software. I'm using qt and cmake to build an my project. There is a hudson plugin for cmake but I prefer to use shell commands:




Note that all shell commands are relative to the $WORKSPACE variable. In the example I use "env" to show my environment.
Cmake use qmake in your PATH to find the QT framework so we set the PATH variable using a parameterized build:
That's all. If you wanna try here there is a small example using qt, cmake and git.

In the next post I want to integrate a test suite and make hudson run it.
Bye!

1 comment:

  1. You saved not just my day ...
    YOU SAVED MY DAY, WEEK, MONTH, ...
    Thank you, Thank you.

    I am new to each one of the piece here -- hudson, cmake, even QT. So far I have been on C++ using VS, but now want it platform independent.

    I am still on Windows so will have to use cmake instead of shell (since i do not wish to make it windows specific).

    Will watch out how you integrate testing. Hudson has plug-ins for CppUnit and CppCheck. I am interested in setting up both. I am not happy with CppUnit by itself but Hudson does not support much else for C++ unit tests.

    Next on my list is doxygen. There's a hudson plugin for that too.

    ReplyDelete