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?

  • Is there an effort to develop build-oriented file system with automatic change detection of files?
  • How do I avoid issues with “Protected Mode” using IEDriverServer in Selenium?
  • How to dynamically pick a git branch to use in Jenkins build
  • How/When does Execute Shell mark a build as failure in Jenkins?
  • Version control solution for a build system that produces a 4GB ISO
  • How can I modify the Load Balancing behavior Jenkins uses to control slaves?
  • Why did my TeamCity build stop working?
  • Variable from a property file used in email trigger script in JENKINS
  • ANT checkout task fails
  • git repository gives 403 error while connecting from jenkins in linux
  • Can I import a groovy script from a relative directory from a Jenkinsfile?
  • Maven plugin for versioning and minifying javascript
  • 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.