Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get git branch name in build process

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 ?

like image 395
PeterMmm Avatar asked Oct 26 '25 18:10

PeterMmm


1 Answers

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?)

like image 157
hhappel Avatar answered Oct 29 '25 08:10

hhappel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!