Skip to content

Instantly share code, notes, and snippets.

@lwis
Created December 27, 2015 10:21
Show Gist options
  • Select an option

  • Save lwis/9c4eb28ca8872c38c11a to your computer and use it in GitHub Desktop.

Select an option

Save lwis/9c4eb28ca8872c38c11a to your computer and use it in GitHub Desktop.
Git tag Gradle build
def getGitCommit = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
android {
defaultConfig {
versionName "1.2.3-" + getGitCommit()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment