Last active
December 31, 2015 16:29
-
-
Save lifuzu/8013767 to your computer and use it in GitHub Desktop.
Gets the version name from the latest Git tag
This file contains hidden or 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
/* | |
* Get the current branch name | |
*/ | |
def getCurrentBranchName = { -> | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'symbolic-ref', 'HEAD', '--short' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim() | |
} |
This file contains hidden or 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
/* | |
* Gets the version name from the latest Git tag | |
*/ | |
def getVersionName = { -> | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'describe', '--tags' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim() | |
} | |
/* | |
Reference: | |
http://ryanharter.com/blog/2013/07/30/automatic-versioning-with-git-and-gradle/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to call it?
retval = getVersionName()