Sunday, May 18, 2008

Accessing Hudson Variables with a Free-Style Project

Here is a great article on creating a manifest file containing hudson variables so that you can know exactly what build number and svn number built your artifact. However, in my case I wanted to create a properties file under my maven2 project under src/main/resources and let maven filtering take care of the rest. But for some reason it wouldn't work. After some further research, I eventually found out that free-style projects appear to not work the same as a maven2 project in hudson when trying to access hudson variables.

In summary, hudson variables work as expected when you create a maven2 project in hudson. With a free-style project you have to perform an extra step. Why, I don't know; I am sure there is a good reason. It's just too late to figure it out.

Here are the extra steps you can follow to create a properties file containing hudson values.

Update POM
In your projects POM or parent POM add the following properties at the bottom

Create a properties file
Create a file under your maven2 projects src/main/resources directory.

Now add this to it



chadbeaudin said...

I did this and my resultant that gets put in the jar does not have the variables replaced with the Hudson build values.
Any clues?

chadbeaudin said...

I found my problem.
You must have a "resource" section defined in your pom.

You can see an example of it here:

Thanks for posting how to do this James.

chadbeaudin said...

You also must be aware that filtering of the resource directory will corrupt binary files. The fix is described at the bottom of the following link. You must set up mutually exclusive resource sets.

Term Papers said...

I have been visiting various blogs for my term papers writing research. I have found your blog to be quite useful. Keep updating your blog with valuable information... Regards