tags:

views:

67

answers:

1

I am looking for a way to capture the unique SNAPSHOT build number that was generated during the 'mvn deploy' phase of the build. I would like to be able to pass this version (during a Hudson build) to another process used for deploying to an application server. The key here is being able to capture the exact Maven SNAPSHOT build number, such as:

foobar-0.4-20100707.060244-11.war

I have noticed that Hudson is capturing this information if you archive the maven build artifact, but it is not clear how I can expose this variable and pass it to another job (which is what I want to do). I can see this variable in the Hudson Home directory, like so:

/hudson/jobs/JOB_NAME/builds/24/org.ace.widgets$foobar/archive/org.ace.widgets/foobar/0.4-20100707.060244-11

Any Maven and/or Hudson experts out there that have any clue how to expose the SNAPSHOT build number? Hudson is doing it?

A: 

Check out my answer to this slightly different problem where I use GMaven to access the project metadata after deploy. What they have in common is that you have to access the unique build number. So you could adapt the script so that after it has read the project meta data (after deploy) it stores the unique version in the maven properties:

pom.properties['uniqueVersion'] = uniqueVersion

If the appserver-deploy-process is also a maven plugin, access this property, otherwise store it as a file using something like this:

new File(pom.build.directory, "uniqueVersion.txt").text = uniqueVersion

Now you can pick it up from target/uniqueVersion.txt using a shell script or so.

seanizer