How to use Jenkins Multi-Configuration (Matrix) type Projects?

DTI-Matt picture DTI-Matt · May 29, 2014 · Viewed 9.9k times · Source

Jenkins official Wiki page for Matrix projects isn't really helping me; so I have a few questions.

We're trying to build a couple of projects that are all essentially the same, just some are being branded differently for our customers. In other words, the software / tests / etc. are all identical, except for some tweaks to turn BrandA into BrandB (or BrandC, etc.)

I figure I should be using a Matrix project to create builds for BrandA, BrandB, etc. While I haven't figured out all my steps yet (including how to rename executables after they're built) I know that I will need to pass the Brand Name to many of my Jenkins Powershell scripts during the build process, and then use that brand n the script.

How do I get these variables into my scripts? Are they automatically passed in to every build step in Jenkins? What is the variable name to use?

Finally, is there a good resource on building these multi-configuration projects in Jenkins? I can't seem to find anything comprehensive online.

Answer

JZimmerman picture JZimmerman · May 29, 2014

If you usually build the job for BrandA and only occasionally for BrandB and BrandC a matrix project may not be what you want. I recommend, instead, using a parameterized job where the brand is a parameter whose default value is BrandA. If the parameter is named BRAND the parameter is accessible in all of the builds and publish steps with ${BRAND} and as an environment variable as %BRAND%.

I refer you to the parameterized build wiki for more details.