/**
* 从 git tag 中获取应用的版本名称
*
* @return git tag 的名称
*/
def getAppVersionName() {
def stdout = new ByteArrayOutputStream()
// exec 是 Project 类中的一个方法
exec {
commandLine 'git','describe','--abbrev=0','--tags'
setStandardOutput(stdout)
}
return stdout.toString().replace("\n", "") // 移除最后的换行符
}