git.branch showing commit Id instead of branch name. I am using ${git.branch} in my version.jsp to display the branch.
Below is the what i added in POM. I am not sure if this is the issue with Maven as my local build works fine but have issue with TFS build.
what does TFS reference?
I faced the same issue on VSTS build agents. It turns out VSTS git checkout happens in detached mode based on last commit on particular branch, hence a commit-id in place of branch name. I implemented a workaround:
<configuration>
<replacementProperties>
<replacementProperty>
<property>git.branch</property>
<token>^.*$</token>
<!--NOTE: required for VSTS env where checked out code is not on a branch-->
<value>${env.BUILD_SOURCEBRANCH}</value>
<regex>true</regex>
</replacementProperty>
</replacementProperties>
</configuration>
Works locally as well if _env.BUILD_SOURCEBRANCH_ is not available it fallback and use the git branch
I tried this but it didnt work. I have added the above as part of commit id plugin. Or Do i have to add this maven war plugin.
The workaround worked . I have used sourcebrach name instead of just source branch . Also replacement property will only work if 2.2.3 version and above is used . I was using 2.1.13 initially .
@sunnyverma88 how did you solve this problem pls
Most helpful comment
I faced the same issue on VSTS build agents. It turns out VSTS git checkout happens in detached mode based on last commit on particular branch, hence a commit-id in place of branch name. I implemented a workaround:
Works locally as well if _env.BUILD_SOURCEBRANCH_ is not available it fallback and use the git branch