Monday, April 21, 2008

Maven SNAPSHOT Traceability

So your scrum team is creating non-unique SNAPSHOT versioned artifacts throughout your sprint. How do trace that SNAPSHOT version back to a baseline that is of any QA relevance (build number, subversion revision, datetime stamp)?

<format property="now" pattern="MM/dd/yyyy hh:mm" unit="hour" />
<property name="build.version" value="${version} (private-${now}-${})" />
<property name="" value="hudson-${BUILD_NUMBER}, subversion-${SVN_REVISION}" />

<!-- put the version file -->
<echo message="The build id is: ${build.version}" />
<mkdir dir="target/${}/" />
<echo file="target/${}/">version=${build.version} ${}


<!-- for releases, just use the POM version. -->

This little piece of magic creates a file that contains some valuable information.

version=1.1.0-SNAPSHOT (private-04/21/2008 02:23-jblack), hudson-453, subversion-1124

When you do a formal release, specify the -Prelease profile to have this file simply hold the pom version.

For the plugin configuration above, this file gets put in a war project root webapp directory, suitable for immediate viewing from your browser!

The mad props for this idea go to Kohsuke. :)

1 comment:

Chad Gallemore said...

Thanks Jeff, I guess I missed this post when you initially posted it. Maybe now I can get Malcolm off my back about getting the build number included in our artifacts :)