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
<project>
....
<properties>
<build.number>${BUILD_NUMBER}</build.number>
<build.id>${BUILD_ID}</build.id>
<job.name>${JOB_NAME}</job.name>
<build.tag>${BUILD_TAG}</build.tag>
<executor.number>${EXECUTOR_NUMBER}</executor.number>
<workspace>${WORKSPACE}</workspace>
<hudson.url>${HUDSON_URL}</hudson.url>
<svn.revision>${SVN_REVISION}</svn.revision>
</properties>
</project>
Create a properties fileCreate a application.properties file under your maven2 projects src/main/resources directory.
Now add this to it
build.number=${build.number}
build.id=${build.id}
job.name=${job.name}
build.tag=${build.tag}
executor.number=${executor.number}
workspace=${workspace}
hudson.url=${hudson.url}
svn.revision=${svn.revision}
I did this and my resultant application.properties that gets put in the jar does not have the variables replaced with the Hudson build values.
ReplyDeleteAny clues?
I found my problem.
ReplyDeleteYou must have a "resource" section defined in your pom.
You can see an example of it here:
http://maven.apache.org/guides/getting-started/index.html#How_do_I_filter_resource_files
Thanks for posting how to do this James.
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.
ReplyDeletehttp://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
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
ReplyDelete