Thursday, November 19, 2009

Strategies for managing many small maven2 and hudson projects

So you finally decided to structure your maven2 projects properly, e.g. identify the correct set of plugin versions/configurations that work well in your environment, introduce a set of corporate POMs.... You also decided to clean up your hudson usage, use new plugins, etc...

You have to change many POMs, probably adapt hudson projects as well. You don't want to change all those configurations one by one. The good news is that both maven and hudson use XML as storage for the config files.

Here are some tips and tools you might want to use:

Managing maven POMs

  1. I like to have my maven POMs to be ordered and formatted properly. It's helps a lot when looking at diff files. So I wrote these little tools to help me [1] [2]. Note you could reuse those tools for managing any kind of XML files (e.g. web.xml, abator config files, etc...).
  2. similarly if you have many POMs to transform, you can use the same programs to help you applying transformations. E.g.
    add/update an tag, convert some dependencies, etc...
  3. you can also use the maven versions plugin to make some specific transformations. e.g. mvn versions:update-parent

Note: the xml tools I wrote don't know the maven model, while I presume the Maven2 versions plugin does.

Managing hudson configs

  1. Groovy scripts are great. See some examples here [3]
  2. Hudson project copying. Create a template project and recreate your projects based on that one
  3. Modify the config.xml files and reload them from hudson. Advised to use scripts (e.g. groovy/ruby/python or custom groovy_xml_tools transformation scripts) to transform your hudson project files. I've had strange issues when doing heavy changes (e.g. converting free style to maven2 projects, etc...). In those case, I falled back on option 1 and 2

Getting overview of your Hudson project configs

  1. use the groovy console
  2. use standard unix tools. By using ssh, together with ssh keys and installing simple scripts on your server, you can do things like

    ssh hudsonserver " mavenOpts"

    In this particular case, contains

    grep $1 $HUDSON_HOME/jobs/*/config.xml

Further notes

I like using templates in order to achieve some kind of standardization when managing many small projects in a small team. This doesn't fit all environments, but in some cases it is good to avoid variation across your environment. When I was contributing to cruisecontrol I spent a bit of time implementing full project pre-configuration. This was I think one of the best feature of CruisecControl. To my knowledge Hudson doesn't support that today, but you can achieve similar results it by generating your files, reconfiguring on the fly using the groovy console, etc...

Drop me a line if you find a use of the tools below !

[3] some Hudson Script receipes

1 comment:

  1. HI Jerome,

    I'm trying to use your maven tools but I have an issue. The script ask if I want to commit and it don't do it when I reply "y".
    Did you try it on macos ?