qeat7g
Last Updated: February 25, 2016
·
670
· carlosefonseca
7604a48be008a79e1ee10be31ca95220

Adding git revision code to Android

This gets the current git revision as a variable on the BuildConfig file. I'm sending it to Crashlytics as a piece of data so I can figure out easily what commit does that stack trace relates to.

android {
    buildTypes {
        debug {
            buildConfigField "String", "GIT", "\"${gitRevision()}\""
        }
        release {
            buildConfigField "String", "GIT", "\"${gitRevision()}\""
        }
    }
}

def gitRevision() {
    def cmd = "git rev-parse --short HEAD"
    return cmd.execute().text.trim()
}
Say Thanks
Respond

1 Response
Add your response

14712
7604a48be008a79e1ee10be31ca95220
over 1 year ago ·