Skip to content

Instantly share code, notes, and snippets.

@gabrielbmoro
Last active May 29, 2022 20:01
Show Gist options
  • Save gabrielbmoro/3a27fb7fe0bc6ec2dc440520bf190038 to your computer and use it in GitHub Desktop.
Save gabrielbmoro/3a27fb7fe0bc6ec2dc440520bf190038 to your computer and use it in GitHub Desktop.
Getting version name, and version code from env variables
private static String getVersionName() {
String versionName = "$System.env.ANDROID_VERSION_NAME"
if (versionName == null || versionName.isEmpty()) {
int versionCode = getVersionCode()
return "1.0.$versionCode"
} else {
return versionName
}
}
...
private static int getVersionCode() {
try {
return Integer.parseInt("$System.env.ANDROID_VERSION_CODE")
} catch (NumberFormatException numberFormatException) {
println(numberFormatException.message)
return 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment