The Friday Repost series are copies from my earlier writings. Since I don’t want to loose them, and they might prove useful to others, I’m reposting them on this blog
In our development environment, we use the complete Atlassian suite. We (or actually I) choose this environment because the products integrates so well together, but also because it integrates good with other products, like SpringSource Tool Suite, or, in our case, IntelliJ IDEA. And finally, the Atlassian suite has excellent support for building Grails projects, which, at the moment, is all we do. Simply put, we choose Atlassian because it rocks!
To integrate even better with the Atlassian Build Server (Bamboo), I’ve created a small script which will update the version number of the application with the Build Number. This way, we always know which build is running where. To do so, I created the following script.
includeTargets << grailsScript("_GrailsEvents") target('default': "Sets the current application version") { def buildNumberFile = new File('build-number.txt') if (buildNumberFile.exists()) { def props = new Properties() buildNumberFile.withInputStream { stream -> props.load(stream) } def buildNumber = props["build.number"] metadata.'app.version' = metadata.'app.version' + ".${buildNumber}" metadata.persist() event("StatusFinal", ["Application build number updated to ${buildNumber}"]) } }
This script will look for a file called ‘build-number.txt’, which is produced by the Build Number Stamper Plugin, and put in the working directory. This file is read by the script, and it updates the version number in application.properties, which will result in a war file produced by the build in the following format ‘
As an extra, we’ve show the current version of the application in the source of our HTML. We do this by reading the version number from the application.properties with the following tag:
<g:meta name="app.version"/>
This will display the version number of the application, and will allow you to relate issues to a build number, to avoid miscommunication about the deployed application!
The post Friday Repost: Grails and Bamboo appeared first on Jworks.