This build number insertion approach enables us to easily identify from both a test deployment or a customer deployment which Hudson build was used, and which SVN revision number was used simply by looking at the app.version that I show in the footer.gsp of our app.
To do this is fairly simple. It requires 3 simple steps including 2 changes to your build.xml file that Grails generates for you.
- In my project files, my application.properties looks as follows:
app.version=3.3
... or whatever major minor version your app is on. Ours is currently at 3.3. - In my build.xml file I added a task:
<target name="buildnumber">
<property environment="env"/>
<replaceregexp file="${local.dir}/application.properties"
match="app.version=(.*)"
replace="app.version=\1.${env.BUILD_NUMBER}.${env.SVN_REVISION}"
byline="true"/>
</target>
This task is run as a depends of prod.war. ${local.dir} is actually mapped to '.' in my build file properties, so you can always just make it "./application.properties" in the task above. - prod.war task is changed as follows:
<target name="prod.war" depends="buildnumber" ...
This way, we know which Hudson build is being used, and which SVN revision was used in that build. This helps us in both QM and out in the wild when a customer reports a problem. Also, with SVN we never have to tag a build because the revision number is the tag. If we need to make bug fix changes we can branch from a revision and we're good to go.
No comments:
Post a Comment