I wanted to get the current git branch name to build binaries with a filename that contains the branch name. Is that possible in Netbeans(7.1) with ant ?
If you do not want to deal with env variables (as suggested in the solution above) AND if the git command is available from your command line, an alternate solution would be using ANT exec:
<exec executable="git" outputproperty="git.branch"
failifexecutionfails="false">
<arg line="rev-parse --abbrev-ref HEAD"/>
</exec>
<echo message="Current branch: ${git.branch}"/>
(Solution basically combines http://llbit.se/?p=1876 and How to get the current branch name in Git?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With