How can I access the build number and VCS checkout number in a Gradle script executed by Teamcity?
In Ant I can use ${build.number}
and ${build.vcs.number.1}
respectively.
Thank you.
These are simply JVM system properties that TeamCity sets for the Ant/Gradle JVM. You can access them with the usual Java means, for example System.getProperty("build.number")
.
If you are developing Android application you can access build.number
to update apk file name accordingly:
defaultConfig {
applicationId "com.mydemoci"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "0.7"
ext.buildNumber = System.getProperty("build.number") ?: "Regular"
archivesBaseName = "$applicationId-v$versionName-b$buildNumber"
}
To test locally just run gradlew clean build -Dbuild.number=123
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With