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?

  • Jenkins/Hudson - How to run multiple jobs in parallel more than 1 level deep?
  • Building Eclipse IDE from scratch - how to choose CDT over JDT?
  • TFS Labels in a Build Continuous Environment with Jenkins
  • Xcode build automation scheduled integration bot setting
  • How can I stop an Xcode Archive build if my git working copy is dirty?
  • Jenkins copy directories/files in a build
  • Should you check in your compiled assets to Git?
  • NotSerializableException using Publish Over SSH in Jenkinsfile
  • configure Jenkins “Global Tool Configuration” using CLI / groovy
  • How to list all `env` properties within jenkins pipeline job?
  • Jenkins and maven-buildnumber-plugin
  • In jenkins job, create file using system groovy in current workspace
  • 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 
            DAVRepositoryFactory.setup(); 
            SVNRepositoryFactoryImpl.setup(); 
            FSRepositoryFactory.setup(); 
    
            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() 
            metadata.persist() 
    
        } 
        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()
        return proc.in.text
    }
    
    Git Baby is a git and github fan, let's start git clone.