【发布时间】:2015-07-13 15:18:51
【问题描述】:
我想在清单文件中自动实现更新修订号。
这是我的代码:
def getGitRevision(){
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
args = ['info']
standardOutput = os
}
def outputAsString = os.toString()
def matchLastChangedRev = outputAsString =~ /Last Changed Rev: (\d+)/
ext.gitRev = "${matchLastChangedRev[0][1]}".toInteger()
}
return String.valueOf(gitRev);
}
但它会引发以下错误:
错误:(10, 0) Process 'command 'git'' 以非零退出值 1 结束
【问题讨论】:
-
你可以用 --info 执行它以获取有关失败的扩展信息吗?
-
这个命令在 std err 流上打印什么?
标签: android git gradle revision-history