Jenkins multi-configuration matrix

continuous integrationhudsonJenkinsteamcity

BACKGROUND:

We are planning to migrate from Teamcity to Jenkins. Most of the projects are C/C++ and the source code is in ClearCase and would be using a custom build system. We wouldn't be checking out the source to some machine and do the building, instead all we want is execute build command on the remote ClearCase nodes.

So it's fairly simple when it comes to build configuration of a project in Teamcity(just mention the command, parameters and node). Since the build configurations are simple, we thought Jenkins could provides all the features we are looking for.

QUESTION:

However, we have certain projects which have to be built on different platforms (AIX, LINUX, Windows… 32bit/64bit..etc) and should be built on specific nodes with different build parameters. Teamcity allows us to create a project and create multiple build configurations inside it for each platform. For each build configuration we can specify parameters/build nodes…etc.

When I looked for similar feature in Jenkins, I found multi-configuration project. I understand that we can define an axis for platforms, but I failed to understand how can I specify specific slave node for specific platform. I don't want the build to be executed on all slave nodes. Same can be said about build parameters and build command. I may want different parameters and build commands for each build configuration.

In a multi-configuration project in Jenkins, is it possible to configure each build configuration to have separate slave/command/parameter settings?

Jenkins documentation is not very good in this area. Creating a separate project for each build configuration is not a good idea. If I have 20 projects with 10 platforms, then I end up creating 200 projects in Jenkins. Whereas in Teamcity I can create 20 projects and create 10 build configurations in each project.

Best Answer

If you go into Manage Jenkins->Manage Nodes you can add labels in for your defined nodes. You can possibly add the labels in when you add the nodes, depending on how you create them.

You could do something like define them on their architecture so the platform is the node and if you want more nodes then they can have the same label.

It the job you would do something like this

enter image description here

This takes care of only running the job on the architectures you want.

I think your problem with configuration could be resolved with Job-DSL-Plugin which allows you to create jobs with a purpose built DSL


EDIT: I found a better solution

You can bind platforms to node labels with the PlatformLabel plugin which will add labels to nodes as they are added - you can see these in config Jenkins->manage nodes->click the node

Then in a matrix/multi config job you can use the 'Slaves' axis (note you only get this axis if you have nodes attached) and find all the choices in label section, check the ones you want

enter image description here

To conditionally run a step based on the platform you can use the Run Condition plugin

I used a Regular expression match

Expression: Debian Label: ${ENV,var="PLATFORM"}

which assumes you want to run the step for Debian and that the axis is called PLATFORM

enter image description here

Related Topic