Git-commit-id-maven-plugin: git.branch showing commit Id instead of branch name.

Created on 13 Feb 2018  路  5Comments  路  Source: git-commit-id/git-commit-id-maven-plugin

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.


pl.project13.maven
git-commit-id-plugin
2.1.13



revision




${project.basedir}/../.git

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:

<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

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VK2BEA picture VK2BEA  路  5Comments

Randgalt picture Randgalt  路  5Comments

TheSnoozer picture TheSnoozer  路  7Comments

sta-szek picture sta-szek  路  5Comments

bernardpaulus picture bernardpaulus  路  6Comments