Created
September 25, 2016 11:32
-
-
Save tonilopezmr/18b1491555d71ef9533ac5b12566c5e0 to your computer and use it in GitHub Desktop.
Create auto VersionName and VersionCode
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
def computeVersionName() { | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'describe', '--abbrev=0', '--tags' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim().replaceAll('v', '') | |
} | |
def computeVersionCode() { | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'rev-list', '--count', 'HEAD' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim().toInteger() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment