Active Git branch is "(no branch)" on hudson CI

Viewed 11969

My Ant build.xml script starts with

<property environment="env"/>
<echo>GIT_BRANCH = ${env.GIT_BRANCH}</echo>
<echo>PWD = ${env.PWD}</echo> 

Hudson CI is setup to build when any branch changes. Console output is...

Commencing build of Revision 90906a63929e9074035eb5b10c71ee055ad3e13c (origin/DPM-48)
GitAPI created
Checking out Revision 90906a63929e9074035eb5b10c71ee055ad3e13c (origin/DPM-48)
[workspace] $ git.exe checkout -f 90906a63929e9074035eb5b10c71ee055ad3e13c
[workspace] $ cmd.exe /C '"C:\Program Files\WinAnt\bin\ant.bat" -file build.xml ...'
 [echo] GIT_BRANCH = ${env.GIT_BRANCH}
 [echo] PWD = /cygdrive/d/.hudson

From the console output, Hudson knows it is building topic branch DPM-48 but environment variable GIT_BRANCH is not set and 'git branch' returns that git is at a 'detached HEAD' state

* (no branch)
master
DPM-48

What I want to know is which branch I'm building on hudson. There must be a way to do this.

3 Answers
Related