Just an example how use commits count value as a build number of app.
buildscript {
//...
}
repositories {
//...
}
def cmd = ‘git rev-list –all –count’ def gitVersion = cmd.execute().text.trim().toInteger() println “=== Building version ” + gitVersion.toString()
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
//...
versionCode gitVersion versionName “1.0.” + gitVersion
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
}
}
signingConfigs {
release {
//...
}
}
productFlavors {
play {
//...
}
}
}
dependencies {
//...
}