Skip to content

Instantly share code, notes, and snippets.

@tonilopezmr
Created September 25, 2016 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonilopezmr/18b1491555d71ef9533ac5b12566c5e0 to your computer and use it in GitHub Desktop.
Save tonilopezmr/18b1491555d71ef9533ac5b12566c5e0 to your computer and use it in GitHub Desktop.
Create auto VersionName and VersionCode
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