Is there a way to read the value versionName
from the build.gradle
file of an Android project to use it in bash?
More precisely: How can I read this value from the file and use it in a Travis-CI script? I'll use it like
# ANDROID_VERSION=???
export GIT_TAG=build-$ANDROID_VERSION
I set up a Travis-CI like described in this post https://stackoverflow.com/a/28230711/1700776.
My build.gradle: http://pastebin.com/uiJ0LCSk
Expanding on Khozzy's answer, to retrieve versionName of your Android package from the build.gradle, add this custom task:
task printVersionName {
doLast {
println android.defaultConfig.versionName
}
}
and invoke it so:
gradle -q printVersionName