Skip to content

Instantly share code, notes, and snippets.

@mark-software
Last active March 13, 2022 03:45
Show Gist options
  • Save mark-software/e034e326ad3a1b6f110c08fb885cc4a9 to your computer and use it in GitHub Desktop.
Save mark-software/e034e326ad3a1b6f110c08fb885cc4a9 to your computer and use it in GitHub Desktop.
Example showing how to read a build number from a CI system for automatic build numbers
android {
//version.properties is only used to get the version number from CircleCi
def versionFile = file('../.signing/version.properties')
def buildNumber = 456
if(versionFile.canRead()) {
Properties props = new Properties()
props.load(new FileInputStream(versionFile))
//Add skip_appcenter_release in a commit message to develop/master/release if you don't want a build to be created by CircleCi
if(props['VERSION_CODE'] != null) {
def circleBuildNumber = props['VERSION_CODE'].toInteger()
buildNumber = circleBuildNumber - 3870 //subtract offset to get close to our real build number
}
}
defaultConfig {
versionCode buildNumber
versionName "1.2.3"
...
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment