I am having problems with JGit version 3.0.0.201306101825-r. Here is my clone function:
public static void cloneRepository(String localRepositoryPath, String remoteRepositoryURI, String branch, String username, String password) throws IOException, InvalidRemoteException, GitAPIException {
File workDir = createFolder(localRepositoryPath);
CloneCommand clone = Git.cloneRepository();
clone.setBare(false);
clone.setCloneAllBranches(false);
clone.setBranch(branch);
clone.setDirectory(workDir).setURI(remoteRepositoryURI);
if (StringUtils.isNotEmpty(username)) {
UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(username, password);
clone.setCredentialsProvider(credentials);
}
Git git = clone.call();
}
I am trying to clone a repository from gerrit with everyone having access to read it. 'git clone ssh://gerrit.xx.com:29418/project/test' works correctly from terminal but with Jgit I cannot clone the repository. This is what I am getting as an error:
[INFO] [talledLocalContainer] Caused by: org.eclipse.jgit.errors.TransportException: ssh://gerrit.xx.com:29418/project/test: Auth fail
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] ... 55 more
[INFO] [talledLocalContainer] Caused by: com.jcraft.jsch.JSchException: Auth fail
[INFO] [talledLocalContainer] at com.jcraft.jsch.Session.connect(Session.java:491) [jsch-0.1.49.jar:]
[INFO] [talledLocalContainer] at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116) [org.eclipse.jgit-3.0.0.201306101825-r.jar:3.0.0.201306101825-r]
[INFO] [talledLocalContainer] ... 62 more
[INFO] [talledLocalContainer]
Ideas how to fix this are more than welcome!