Jenkins 无法在 Windows 上通过 Git/SSH 克隆 Git 存储库 [英] Jenkins can not clone Git repository over Git/SSH on Windows
问题描述
我已经在 Windows 2008 32 位上通过 Git/SSH 在 Jenkins 中成功克隆了 Git 存储库.当我尝试在 64 位 Windows 2008 上执行相同操作时,控制台输出 页面卡在此处:
I have successfully cloned Git repository in Jenkins over Git/SSH on Windows 2008 32-bit. When I tried to do the same on Windows 2008 64-bit, Console Output page gets stuck here:
Démarré par l'utilisateur anonymous
Checkout:book / C:Jenkinsworkspaceook - hudson.remoting.LocalChannel@1da691a
Using strategy: Default
Last Built Revision: Revision 5d7ce4ae23c91fb201ee005e6db17bcd795ca965 (origin/HEAD, origin/master)
Checkout:book / C:Jenkinsworkspaceook - hudson.remoting.LocalChannel@1da691a
Cloning the remote Git repository
Cloning repository origin
当我停止构建时(被卡在那里几分钟后),我收到了其余的错误消息:
When I stop the build (after a few minutes of being stuck there), I get the rest of the error message:
ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:zeljkofilipin/watirbook.git
ERROR: Cause: Error performing command: C:Gitingit.exe clone --progress -o origin git@github.com:zeljkofilipin/watirbook.git C:Jenkinsworkspaceook
null
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1042)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:968)
at hudson.FilePath.act(FilePath.java:785)
at hudson.FilePath.act(FilePath.java:767)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:968)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:567)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:455)
at hudson.model.Run.run(Run.java:1404)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:230)
- 我可以在两台机器上通过 Jenkins 的 Git 只读 URL
git://github.com/zeljkofilipin/watirbook.git
克隆存储库 - 我可以从两台机器上的命令行通过 Git/SSH URL
git@github.com:zeljkofilipin/watirbook.git
进行克隆 - 我可以在 32 位机器上通过 Git/SSH URL 从 Jenkins 克隆,但不能在 64 位机器上.
- I can clone the repository via Git read-only URL
git://github.com/zeljkofilipin/watirbook.git
from Jenkins on both machines - I can clone via Git/SSH URL
git@github.com:zeljkofilipin/watirbook.git
from the command line on both machines - I can clone via Git/SSH URL from Jenkins on 32-bit machine, but not on 64-bit machine.
- 同时安装了 Msysgit 和 Cygwin:MSysgit 对我来说效果更好 - 但我假设您也在使用它
- 有些人使用
比cmdgit.cmd ingit.exe 更幸运 - 确保您的从站以同一用户身份运行(这不是基于服务的安装的默认设置).. - 哦,我明白您也明白了
- 为 windows slaves 显式设置
HOME
变量 - 基本上确保在 Jenkins 下使用相同的 .ssh 密钥.
- 对于调试,我发现创建一个没有 SCM 的测试作业很有用,但在执行 shell/批处理"构建步骤中运行
git clone
.那应该会透露更多信息.顺便说一句,你可以在同一步骤中做一个env
,也许ls %HOME%/.ssh
- a mix of both Msysgit and Cygwin installed: MSysgit worked better for me- but I assume you're using that too
- some people have more luck with
<MSYSGIT_ROOT>cmdgit.cmd
than<MSYSGIT_ROOT>ingit.exe
- making sure your slave runs as the same user (which is not the default upon service-based installs).. - oh I see you got that too
- setting
HOME
variable for windows slaves explicity - basically make sure the same .ssh keys are reached when under Jenkins.
- for debugging, I found it useful to create a test job with no SCM, but run
git clone
in an "Execute shell/batch" build step. That should reveal a bit more info. BTW, you can do anenv
in the same step and maybels %HOME%/.ssh
我能注意到两台机器之间的唯一区别(不算一台是我笔记本电脑上的虚拟机,另一台是瑞士的真机)是第一个是 32 位的,第二个是 64 位的-位.
The only difference I can notice between the two machines (not counting that one is a virtual machine on my laptop, and another is a real machine in Switzerland) is that the first one is 32-bit and the second one is 64-bit.
不确定这是否相关,但是 32 位机器的位置设置为克罗地亚,而 64 位机器的位置设置为瑞士(正如您从 Git 输出的法语版本中看到的那样).
Not sure if that could be related, but 32-bit machine has location set to Croatia, and 64-bit machine to Switzerland (as you can see from Git output in French).
有关更多信息,请参阅我的博客文章:Jenkins、Windows 和 Git
For more information please see my blog post: Jenkins, Windows and Git
推荐答案
我最近经历了这些痛苦.尤其令人沮丧的是在这种情况下缺少错误日志:可能是因为 MSysgit 在尝试恢复时会在控制台上提示用户 - 这不会通过 Jenkins 控制台.
I've gone through these pains recently. Especially frustrating is the lack of error logs in this scenario: probably because MSysgit prompts user on the console when trying to recover - which doesn't get through Jenkins console.
根据我的经验,这里有几个需要注意的关键要素:
Based on my experience here are a few key elements to watch for:
我认为以上是什么给了我一个支持 git 的 Windows 7 64 位 Jenkins 从站 - 尽管我认为这与其他一些精细的配置细节有关,而不是 64 位和 32 位.总之祝你好运!
I think the above is what gave me a working a Windows 7 64bit Jenkins slave with git support - although I thought this had more to do with some other fine config detail than with 64 vs 32 bits. Good luck anyhow!
这篇关于Jenkins 无法在 Windows 上通过 Git/SSH 克隆 Git 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!