Created
June 6, 2016 14:48
-
-
Save baybatu/fc70b2de3e0b8f388738d8868a92b10a to your computer and use it in GitHub Desktop.
Getting system startup date and build version in Grails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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