2012-02-24 110 views

回答

4

如果你不想处理ENV变量(如上面的解决方案建议),如果git的命令可从您的命令行,一个替代的解决方案将使用ANT EXEC:

<exec executable="git" outputproperty="git.branch" 
failifexecutionfails="false"> 
<arg line="rev-parse --abbrev-ref HEAD"/> 
</exec> 
<echo message="Current branch: ${git.branch}"/> 

(溶液基本上结合http://llbit.se/?p=1876How to get the current branch name in Git?

+0

当我在特拉维斯CI尝试这样做,它只是印刷'当前分支:HEAD' – 2017-03-29 03:41:23