Last active
May 29, 2022 20:01
-
-
Save gabrielbmoro/3a27fb7fe0bc6ec2dc440520bf190038 to your computer and use it in GitHub Desktop.
Getting version name, and version code from env variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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