-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Jenkins 2.440.3
I want to retrieve the code branch name during Java packaging. I am using the git-commit-id-plugin. In the git.properties file generated when running on my local computer, the value of git.branch is the branch name. However, in the git.properties file generated during packaging on the Jenkins environment server, the value of git.branch is the commit ID.
- The Git Commit ID Maven Plugin from https://github.com/ktoso/maven-git-commit-id-plugin also fails to extract the branch (unsure why)
Here jenkins checks out the code in detached head mode.
Note:- We had reached out to manitainer for this plugin and he asked to get fix from jenkins, Please find the link below for your refernce.
https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/325
For historic compatibility reasons, the Jenkins git plugin creates a "detached head" checkout rather than performing a checkout to a specific branch. It is surprising to many users, but we cannot change the default behavior without breaking many users that depend on the default behavior.
"Checkout to specific local branch" is an option that you can add to git checkout in Jenkins Pipeline, Jenkins freestyle, and other Jenkins jobs that use the git plugin. When that option is enabled, then the checkout will create a local branch with the specified name.