我尝试创建一个本地分支并将其推送到远程。当我使用以下代码创建本地分支,并且当pushCommand.call()
方法中的pushHotfixBranchToRemote()
执行时,它会抛出异常
org.eclipse.jgit.api.errors.TransportException: ssh://approot@192.168.57.65:22 / u01 / gitroot / apdt_v16_test / dev / appbi.git:Auth fail
上述情况发生在Linux机器上运行,其中克隆源存在于同一台机器中,裸机存在于另一台机器中。
但是当我在我的本地机器(windows)中尝试使用相同的机器但裸机在不同的驱动器中时,它的工作正常。
这些问题的一些答案说,我们要检查.ssh文件夹。但我不知道任何关于它的事情。请帮助我解决问题
private void createLocalHotFixBranch() {
CreateBranchCommand createBranchCommand = null;
try {
portalLogger.debug("Inside createLocalHotFixBranch()");
createBranchCommand = gitObject.branchCreate();
createBranchCommand.setName(GitBranchConstants.hotFixBranchName + "_" + releaseVersion)
.setStartPoint("origin/" + GitBranchConstants.releaseBranchName).call();
} catch (GitAPIException e) {
portalLogger.error("Error occured in createLocalHotFixBranch --> " + e.getMessage());
e.printStackTrace();
}
}
private void pushHotfixBranchToRemote() {
PushCommand pushCommand = null;
try {
portalLogger.debug("Inside pushHotfixBranchToRemote()");
pushCommand = gitObject.push();
pushCommand.setRemote("origin");
pushCommand.setRefSpecs(new RefSpec(GitBranchConstants.hotFixBranchName + "_" + releaseVersion + ":"
+ GitBranchConstants.hotFixBranchName + "_" + releaseVersion));
pushCommand.call();
} catch (GitAPIException e) {
portalLogger.error("Error occured in pushHotfixBranchToRemote --> " + e.getMessage());
e.printStackTrace();
}
}
例外是
org.eclipse.jgit.api.errors.TransportException: ssh://approot@192.168.57.65:22/u01/gitroot/apdt_v16_HotfixTest/dev/core.git: Auth fail
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:160)
at com.echain.project.HotFixBranchCreationTest.pushHotfixBranchToRemote(HotFixBranchCreationTest.java:121)
at com.echain.project.HotFixBranchCreationTest.initiateHotfixCreationProcess(HotFixBranchCreationTest.java:65)
at com.echain.project.HotFixBranchCreationTest.main(HotFixBranchCreationTest.java:169)
Caused by: org.eclipse.jgit.errors.TransportException: ssh://approot@192.168.57.65:22/u01/gitroot/apdt_v16_HotfixTest/dev/core.git: Auth fail
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:159)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)
at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:320)
at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:166)
at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
at org.eclipse.jgit.transport.Transport.push(Transport.java:1200)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
... 3 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:512)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
... 9 more