从Jenkins读取build.gradle的versionName [英] Read versionName of build.gradle from Jenkins

查看:541
本文介绍了从Jenkins读取build.gradle的versionName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Jenkins用于我的Android应用程序构建. 在每个版本中,我都会得到一些信息,例如版本号等.

I'm using Jenkins for my Android app builds. On every build, I get some info, like build number, etc...

我正在寻找一种在詹金斯(Jenkins)建立工作时读取build.gradleversionName值的方法.我知道我们可以使用$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_NUMBERenv 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆