Using Jenkins build parameters in SCM fields

At my current client, I’m doing some prototype work and controlling my CI process with Jenkins. I’ve been using Jenkins/Hudson for years, but usually with a group of folks, and not while flying solo. After installing the requisite Chuck Norris plugin (5 projects in a row!), and setting up all of the typical jobs, I thought it might be handy to have a job that would prepare a ‘release’- a checkout and build of a specific tag from CVS, where the tag is provided via a parameter given to the job via the parameterized build style that Jenkins provides.

So, I set up a parameterized build and created a string parameter called ‘TAG’. I thought I’d just drop ‘${TAG}’ into the ‘branch/tag’ field in the ‘Branch’ field in the Source Code Management section of my job config. Shortly thereafter, I ran into my first unresolved Jenkins issue – JENKINS-3230. Build parameters aren’t available in the Source Code Management section of the job config. The ticket doesn’t appear to have moved in a while, and being in a jam, I thought I’d work around first, then revisit contributing to a fix or finding a more permanent solution later.

Fortunately, the solution is simple. Just remove the calls from the SCM section of the job config (change that section to ‘None’) and replace with equivalent (in my case) instances of ‘Execute Windows batch command’.

For me, the command ended up looking like this:

cvs -Q -z3 -d :pserver:me@myserver:2402/cvs/repositories/myrepository co -P -r %TAG% my.module.name

If it’s a maven build, and you’re executing top-level POMs, you’ll also have to change subsequent ‘Invoke top-level Maven targets’ sections in your config to specify the parent project name in the POM field (my.module.name/pom.xml), instead of just using the default (pom.xml).

It’s just a bit more maintenance (and kind of a hassle to have to remember all of the CVS parameters), but it works!

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s