Wednesday, September 26, 2012

Create Matrix jobs with Hudson


I've been making some improvements to our use of Hudson recently that have been really helpful.

One of this was using the matrix feature. The matrix feature is really nice, that lets you configure jobs with multiple configurations, running on multiple hosts etc. You can also set up your own User-defined axis.

Here, I would like to show how to set up matrix/multi-configuration jobs in Hudson, that I used for my project.

I was trying to set up my project for MySQL connector python.
The challenge was to setup a job involving multiple variants as below
  • multiple python versions,
  • multiple server (MySQL) versions

and so, I chose a matrix job, that finally looked like below -


 
 
 
 
 
Looking at console output, you would see -
Triggering python2.6,mysql_56,oel
Triggering python2.7,mysql_55,oel
Triggering python3.3,mysql_56,oel
Triggering python3.3,mysql_55,oel
Triggering python2.6,mysql_55,oel
Triggering python2.7,mysql_56,oel
 
Here is how you go about creating it.

Go to Hudson web console (which would be something like <your Hudson server name:port>)
Click 'New Job' -> choose 'Build multi-configuration project' (seen below)
 

which opens up a configure job window for you, where you choose your Source Code Management (I chose 'Bazaar' repository for my job). You can also choose the 'Build Trigger' as 'Poll SCM' or 'Build periodically' etc.
Now the main important configuration here is 'Configuration Matrix' (seen below)

 










Choose 'User-defined' Axis, Add name/value pairs for python versions, server versions (seen below)
Also add the 'Slaves' Axis for choosing the slaves (test boxes/VMs) you want to run your tests on. You can configure more than 1 boxes with different OS/platforms, though to not overly complicate the matrix, I chose 1 box here and decided to replicate the job for different OS separately.
You might also want to choose the option 'Tie parent build to a node' (seen below)




































Choose your 'Build step' (I have chosen 'Execute shell') , add the code and save the job.
Job done :).The generated matrix and result page looks as below -

Create Multi-OS jobs with Hudson




I've been making some improvements to our use of Hudson recently, that have been really helpful.

One of this was using the multi-configuration jobs. You can create number of Hudson jobs to be tied to 1 particular host/platform. Though it seems quick, you might just end up creating 1 job for each platform, increasing the no. of jobs.

So there are times, you would like to think a bit and setup 1 job that could run your builds/tests across multiple platforms, on multiple hosts etc.

Here, I would like to show how to set up Multi-OS jobs in Hudson, that I used for my project.

Let say, you want to configure your job across multiple *nix variants, that would look something like below -











Here is how you go about creating it.

Go to Hudson web console (which would be something like <your Hudson server name:port>)

Go to 'Manage Hudson' -> 'Manage nodes' -> Add node -> Add a Dumb Slave -> opens up a configuration page. While configuring your slaves add the 'label' that represents the OS the slave is running for ex. oel, rhel, suse, debian etc (see below). 























Add all the slaves (OSs) you want your tests to run on.
Now click 'New Job' -> choose 'Build multi-configuration project' (see below)
















 

which opens up a configure job window for you, where you choose your Source Code Management You can also choose the 'Build Trigger' as 'Poll SCM' or 'Build periodically' etc.
Now the main important configuration here is 'Configuration Matrix' (see below)
 











Choose 'Slaves' Axis for choosing the slaves (test boxes/VMs) you want to run your tests on. You can choose 'Labels' or 'Individual nodes' based on what you would like to be displayed on the result page ('Labels' seemed better to me as that displayed the OS variant name). When you choose 'Labels', you would see all the labels you have attached to your slaves while configuring.

You might also want to choose the option 'Tie parent build to a node' (see below)




























Now choose your 'Build step' (I have chosen 'Execute shell') , add the code and save the job. Remember if you are running across *nix/windows, the same Build step won't work. But here as it is just different *nix variants I could easily choose 'Execute shell'.

Job done :). The generated matrix and result page looks as below -