Skip to content

Instantly share code, notes, and snippets.

@pratul
Created February 9, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pratul/c09c1e6521a9149a3b4a71fd330ae59a to your computer and use it in GitHub Desktop.
Save pratul/c09c1e6521a9149a3b4a71fd330ae59a to your computer and use it in GitHub Desktop.
A gradle method to generate the versionName for an Android app, using git describe.
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (ignored) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment