0

I'm working on a java project. For updating the nexus link dynamically I need to know which branch I'm doing the build, based on that I will fetch snapshot or ear from nexus.

I tried using Jgit to fetch it, but I managed to fetch all the branch from the repo, not the one pulled in the local workspace.

Collection<Ref> refs = Git.lsRemoteRepository()
                         .setHeads(true)
                         .setRemote("My git link").setCredentialsProvider(credentialsProvider)
                         .call();

for (Ref ref : refs) {
                     branches.add(ref.getName().substring(ref.getName().lastIndexOf("/")+1, ref.getName().length()));
                 }
                 Collections.sort(branches);
                 List<String> list1 =  branches;
                 for(String abc:list1){
                     System.out.println(abc);
                 }

I'm trying to fetch the current pulled branch not all the branch present in the repo.

Yadav
  • 129
  • 1
  • 11

0 Answers0