开发者社区> 问答> 正文

Hudson配置git进行构建失败:Error cloning remote repo..报错

软件版本

  1. hudson-3.2.1
  2. git 1.9.2

在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 请再指点下!


展开
收起
kun坤 2020-06-14 07:30:09 1031 0
1 条回答
写回答
取消 提交回答
  • 私有项目,https无权限,建议使用ssh方式。

    PS:我喜欢这种提问风格,使用背景、方式、错误异常一目了然。

    ######你的sshkey配置好没?######

    引用来自“Zoker”的评论

    你的sshkey配置好没?
    我昨天没安装Hudson SSH plugin。
    今天安装好后,在hudson中配置SSH remote hosts,弄不明白了。我是这么填写的:



    如果方便的话,帮我远程处理下。那真是超级感谢!
    qq 356914617
    ######

    我们git不支持ip访问哦,hostname直接填写git.oschina.net    keyfile直接就是你生成的id_rsa.pub,不用写username和pw,有问题在这问也一样,我随时在线:)

    ######

    引用来自“Zoker”的评论

    我们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 -T git.oschina.net 建立一下信任######

    引用来自“Zoker”的评论

    你先ssh -T git.oschina.net 建立一下信任

    这步是之前是做过的。

    这次我将~/.ssh/known_hosts 文件删了。又做了一次信任。又clone一次,验证在我机器上是好使的。再执行hudson构建,仍然报同样的错误。

    注:hudson也是在我机器上。


    ######你工作区下载代码下来没有。。?我的工作区有代码。。但还是没有成功。。######

    我也遇到了同样的问题,ssh key均配置正常 本机通过git都能够正在连接;通过window命令行启动tomcat 没有问题代码可以从git服务器上下载;但只要配置以服务模式启动就提示类似 “com.jcraft.jsch.JSchException: UnknownHostKey:”这样的错误。

    恳求指点一二。在此先谢过各位。

    2020-06-14 07:30:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
新一代高效Git协同模型 立即下载
AGit-Flow:新一代高效Git协同模型 立即下载
AGit-flow:新一代高效Git协同模型 立即下载