grails add svn revision to app.version

I’m trying to add the svn revision to my app.version without requiring ant or some other similar external tool. It looks like I might be able to hook into _Events.groovy to this, but the documentation is relatively sparse.

Anyone know how to do this?

  • Build on commit with subversion
  • How to configure custom maven project structure
  • How can I ensure I'm boot running on the correct branch?
  • Solution/Project name variable in TFS Build 2010
  • Compilation Error when building Giraph
  • In Jenkins, how do builds know who requested them?
  • Run a remote command on all Jenkins slaves via Masters's script console
  • CMake ExternalProject: how to specify relative path to the root CMakeLists.txt?
  • Should I use `git push --force` in my build step
  • Cloak/Exclude folders in Source Settings in tfs 2013 build definition from Team Foundation Git repository
  • Runner type : SSH exec not found in teamcity
  • Jenkins Groovy: What triggered the build
  • 2 Solutions collect form web for “grails add svn revision to app.version”

    This link from the Grails nabble mailing list has the solution you’re looking for. Also putting the code here for completeness:

    In scripts/_Events.groovy

    eventWarStart = { type -> 
        println "******************* eventWarStart *****************" 
        try { 
            // initialise SVNKit 
            SVNClientManager clientManager = SVNClientManager.newInstance(); 
            println "clientManager = " + clientManager.toString(); 
            SVNWCClient wcClient = clientManager.getWCClient(); 
            println "wcClient = " + wcClient.toString(); 
            // the svnkit equivalent of "svn info" 
            File baseFile = new File(basedir); 
            println "baseFile = " + baseFile.toString(); 
            SVNInfo svninfo = wcClient.doInfo(baseFile, SVNRevision.WORKING); 
            println "svninfo = " + svninfo.toString(); 
            def version = svninfo.getURL(); 
            println "Setting Version to: ${version}" 
            metadata.'app.version' = "${version}".toString() 
        catch (SVNException ex) { 
            //something went wrong 
            println "**************** SVN exception **************" 
            println ex.getMessage(); 
    } // End eventWarStart() 

    Grails 3.x, in build.gradle, add svn revision to app version:

    version "1.0.${getSvnRevision()}"
    def getSvnRevision() {
        def proc = "svnversion".execute()
    Git Baby is a git and github fan, let's start git clone.