Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baybatu/fc70b2de3e0b8f388738d8868a92b10a to your computer and use it in GitHub Desktop.
Save baybatu/fc70b2de3e0b8f388738d8868a92b10a to your computer and use it in GitHub Desktop.
Getting system startup date and build version in Grails
/**
* Simple build metadata from system.
*
* To populate application version, just give following parameter while generation WAR package on grails CLI.
*
* $ grails "set-version 1.4" "clean" "war myproject.war"
*
* '1.4' is just an example for build version. If you want to auto generate it by your CI such as Jenkins, then
* create an environment variable and pass it to CLI command.
*
* $ grails "set-version ${BUILD_VERSION}" "clean" "war myproject.war"
*
* Here is the image that shows you how BUILD_VERSION variable can be generated from date formatter in Jenkins:
* https://drive.google.com/file/d/0BxiyyXf6pIAmMnlxTXdXMWoyVUk/view?pref=2&pli=1
*/
def renderStatistics() {
render "System Startup Date: ${new Date(grailsApplication.mainContext.getStartupDate())}\n" +
"Build Version: ${grailsApplication.metadata.getApplicationVersion()}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment