软件版本
在hudson中配置git,如图
path to Git executable 这项还配置过
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Git\bin\git.exe
都报同样的错误。
创建一个job,源码配置如下
运行构建时报错
Started by user anonymous Cleaning the workspace because project is configured to clean the workspace before each build. Checkout:workspace / C:\Windows\System32\config\systemprofile\.hudson\jobs\Job1\workspace - hudson.remoting.LocalChannel@13fbb47 Using strategy: Default Checkout:workspace / C:\Windows\System32\config\systemprofile\.hudson\jobs\Job1\workspace - hudson.remoting.LocalChannel@13fbb47 Cloning the remote Git repository Cloning repository origin ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Could not clone https://git.oschina.net/yufeng217/GitTest.git at hudson.plugins.git.GitAPI.clone(GitAPI.java:255) at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1063) at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1008) at hudson.FilePath.act(FilePath.java:793) at hudson.FilePath.act(FilePath.java:775) at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:1008) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:777) at hudson.model.AbstractProject.checkout(AbstractProject.java:1550) at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:607) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:518) at hudson.model.Run.run(Run.java:1493) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:82) at hudson.model.Executor.run(Executor.java:137) Caused by: hudson.plugins.git.GitException: java.lang.NullPointerException at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:248) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:235) at hudson.FilePath.act(FilePath.java:793) at hudson.FilePath.act(FilePath.java:775) at hudson.plugins.git.GitAPI.clone(GitAPI.java:235) ... 13 more Caused by: java.lang.NullPointerException at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:477) at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:306) at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1111) at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130) at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178) at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:242) ... 17 more Trying next repository FATAL: Could not clone repository hudson.plugins.git.GitException: Could not clone repository at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1074) at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1008) at hudson.FilePath.act(FilePath.java:793) at hudson.FilePath.act(FilePath.java:775) at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:1008) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:777) at hudson.model.AbstractProject.checkout(AbstractProject.java:1550) at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:607) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:518) at hudson.model.Run.run(Run.java:1493) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:82) at hudson.model.Executor.run(Executor.java:137)
求指点!!
-----------------
感谢@Zoker 的答案!
我已经改成 git@git.oschina.net:yufeng217/GitTest.git
不过,又出现一个新问题。在构建时一直处于等待状态,如图
@Zoker 请再指点下!
私有项目,https无权限,建议使用ssh方式。
PS:我喜欢这种提问风格,使用背景、方式、错误异常一目了然。
######你的sshkey配置好没?######我们git不支持ip访问哦,hostname直接填写git.oschina.net keyfile直接就是你生成的id_rsa.pub,不用写username和pw,有问题在这问也一样,我随时在线:)
######我们git不支持ip访问哦,hostname直接填写git.oschina.net keyfile直接就是你生成的id_rsa.pub,不用写username和pw,有问题在这问也一样,我随时在线:)
按照您指导填写的。报错也没管它,可以继续保存。不过编译时仍然报错。我重启过hudson,仍然报错。
把其他的配置项也贴一下。
错误日志:
Started by user anonymous Cleaning the workspace because project is configured to clean the workspace before each build. Checkout:workspace / C:\Windows\System32\config\systemprofile\.hudson\jobs\Job1\workspace - hudson.remoting.LocalChannel@a4b67e Using strategy: Default Checkout:workspace / C:\Windows\System32\config\systemprofile\.hudson\jobs\Job1\workspace - hudson.remoting.LocalChannel@a4b67e Cloning the remote Git repository Cloning repository origin ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Could not clone git@git.oschina.net:yufeng217/GitTest.git at hudson.plugins.git.GitAPI.clone(GitAPI.java:255) at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1063) at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1008) at hudson.FilePath.act(FilePath.java:793) at hudson.FilePath.act(FilePath.java:775) at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:1008) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:777) at hudson.model.AbstractProject.checkout(AbstractProject.java:1550) at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:607) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:518) at hudson.model.Run.run(Run.java:1493) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:82) at hudson.model.Executor.run(Executor.java:137) Caused by: hudson.plugins.git.GitException: org.eclipse.jgit.api.errors.TransportException: git@git.oschina.net:yufeng217/GitTest.git: UnknownHostKey: git.oschina.net. RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4 at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:248) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:235) at hudson.FilePath.act(FilePath.java:793) at hudson.FilePath.act(FilePath.java:775) at hudson.plugins.git.GitAPI.clone(GitAPI.java:235) ... 13 more Caused by: org.eclipse.jgit.api.errors.TransportException: git@git.oschina.net:yufeng217/GitTest.git: UnknownHostKey: git.oschina.net. RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4 at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139) at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178) at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:242) ... 17 more Caused by: org.eclipse.jgit.errors.TransportException: git@git.oschina.net:yufeng217/GitTest.git: UnknownHostKey: git.oschina.net. RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4 at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142) at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121) at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248) at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147) at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1111) at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130) ... 20 more Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: git.oschina.net. RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4 at com.jcraft.jsch.Session.checkHost(Session.java:786) at com.jcraft.jsch.Session.connect(Session.java:342) at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116) ... 27 more Trying next repository FATAL: Could not clone repository hudson.plugins.git.GitException: Could not clone repository at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1074) at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1008) at hudson.FilePath.act(FilePath.java:793) at hudson.FilePath.act(FilePath.java:775) at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:1008) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:777) at hudson.model.AbstractProject.checkout(AbstractProject.java:1550) at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:607) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:518) at hudson.model.Run.run(Run.java:1493) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:82) at hudson.model.Executor.run(Executor.java:137)
这步是之前是做过的。
这次我将~/.ssh/known_hosts 文件删了。又做了一次信任。又clone一次,验证在我机器上是好使的。再执行hudson构建,仍然报同样的错误。
注:hudson也是在我机器上。
######你工作区下载代码下来没有。。?我的工作区有代码。。但还是没有成功。。######
我也遇到了同样的问题,ssh key均配置正常 本机通过git都能够正在连接;通过window命令行启动tomcat 没有问题代码可以从git服务器上下载;但只要配置以服务模式启动就提示类似 “com.jcraft.jsch.JSchException: UnknownHostKey:”这样的错误。
恳求指点一二。在此先谢过各位。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。