I have a Jenkins Maven build where the git client issues the following commands:
git rev-parse --is-inside-work-tree
git config remote.origin.url ssh://git@HOST:PORT/Project/main.git
git --version
git fetch --tags --progress ssh://git@HOST:PORT/Project/main.git +refs/heads/*:refs/remotes/origin/*
git rev-parse refs/remotes/origin/BRANCH_1^{commit}
git rev-parse refs/remotes/origin/origin/BRANCH_1^{commit}
git config core.sparsecheckout
git checkout -f f60bbb84ae0189b766a357a7d589b14c360f9c03
git rev-list 0caaf02f6a5789e54c6562f4d34632eb8e0a7e89
and checks out the requested BRANCH_1
branch. In its workspace, the Git configuration file contains only the following rows:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = ssh://HOST:PORT/Project/main.git
fetch = +refs/heads/*:refs/remotes/origin/*
prune = true
In these circumstances, JGit lists only
HEAD
for
repository.eaxctRef(Constants.HEAD).getLeaf().getName()
and origin
for
git.remoteList().call().get(i).getName()
How could I retrieve, using JGit, the branch name, in this case, BRANCH_1
?
The used JGit version is 4.9.0.201710071750-r.