从Jenkins读取build.gradle的versionName [英] Read versionName of build.gradle from Jenkins
问题描述
我正在将Jenkins用于我的Android应用程序构建. 在每个版本中,我都会得到一些信息,例如版本号等.
I'm using Jenkins for my Android app builds. On every build, I get some info, like build number, etc...
我正在寻找一种在詹金斯(Jenkins)建立工作时读取build.gradle
中versionName
值的方法.我知道我们可以使用$BUILD_NUMBER
env变量获取buildNumber,但是如何获取versionName
?
I'm searching a way to read the versionName
value of in the build.gradle
when Jenkins build the job. I know we can get the buildNumber with the $BUILD_NUMBER
env variable, but how to get the versionName
?
推荐答案
您可以通过添加确定versionName
的执行外壳步骤并将其导出为环境变量来使用
You could do this by adding an Execute Shell step which determines the versionName
, and exporting it as an environment variable using the EnvInject Plugin.
假设您的build.gradle
包含:
versionName = myname
您可以添加以下脚本:
v=$(cat build.gradle | grep versionName | awk '{print $3}')
echo MY_VERSION_NAME=${v} > env.properties
这篇关于从Jenkins读取build.gradle的versionName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!