Jenkins 无法在 Windows 上通过 Git/SSH 克隆 Git 存储库
我已经在 Windows 2008 32 位上通过 Git/SSH 成功克隆了 Jenkins 中的 Git 存储库。当我尝试在 Windows 2008 64 位上执行相同操作时,控制台输出页面卡在此处:
Démarré par l'utilisateur anonymous
Checkout:book / C:\Jenkins\workspace\book - hudson.remoting.LocalChannel@1da691a
Using strategy: Default
Last Built Revision: Revision 5d7ce4ae23c91fb201ee005e6db17bcd795ca965 (origin/HEAD, origin/master)
Checkout:book / C:\Jenkins\workspace\book - hudson.remoting.LocalChannel@1da691a
Cloning the remote Git repository
Cloning repository origin
当我停止构建时(卡在那里几分钟后),我得到了其余的内容错误消息:
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:zeljkofilipin/watirbook.git
ERROR: Cause: Error performing command: C:\Git\bin\git.exe clone --progress -o origin [email protected]:zeljkofilipin/watirbook.git C:\Jenkins\workspace\book
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)
- 我可以通过 Git 只读 URL
git://github.com/zeljkofilipin/watirbook.git
从两台机器上的 Jenkins 克隆存储库 - 我可以通过 Git/SSH URL
克隆<一href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11767865517678657964733f727e7c">[电子邮件受保护]:zeljkofilipin/watirbook.git
从命令行在两台机器上 - 我都可以通过 32 位 Jenkins 的 Git/SSH URL 进行克隆机器上,但不是 64 位机器上。
我能注意到的两台机器之间的唯一区别(不包括一台是我笔记本电脑上的虚拟机,另一台是瑞士的真实机器)是第一台是 32 位,第二台是 64 位。
不确定这是否相关,但 32 位计算机的位置设置为克罗地亚,64 位计算机的位置设置为瑞士(正如您从法语的 Git 输出中看到的那样)。
有关更多信息,请参阅我的博客文章:Jenkins、Windows 和 Git
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:\Jenkins\workspace\book - hudson.remoting.LocalChannel@1da691a
Using strategy: Default
Last Built Revision: Revision 5d7ce4ae23c91fb201ee005e6db17bcd795ca965 (origin/HEAD, origin/master)
Checkout:book / C:\Jenkins\workspace\book - 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 [email protected]:zeljkofilipin/watirbook.git
ERROR: Cause: Error performing command: C:\Git\bin\git.exe clone --progress -o origin [email protected]:zeljkofilipin/watirbook.git C:\Jenkins\workspace\book
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)
- 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
[email protected]: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.
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.
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).
For more information please see my blog post: Jenkins, Windows and Git
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我最近经历了这些痛苦。尤其令人沮丧的是在这种情况下缺少错误日志:可能是因为 MSysgit 在尝试恢复时在控制台上提示用户 - 这不会通过 Jenkins 控制台。
根据我的经验,这里有一些需要注意的关键要素:
方面运气更好;\cmd\git.cmd
比env
,也许ls %HOME%/.ssh
我认为上面的内容给了我一个工作的 Windows 7 64 位 Jenkins 从机与 git 支持 - 尽管我认为这与其他一些精细的配置细节有关,而不是与 64 位和 32 位有关。无论如何,祝你好运!
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:
<MSYSGIT_ROOT>\cmd\git.cmd
than<MSYSGIT_ROOT>\bin\git.exe
HOME
variable for windows slaves explicitygit 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
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!
在最新版本的 git 中,必须使用 %GIT_HOME%/cmd/git.exe,而不是 %GIT_HOME%/bin/git.exe 并找出运行 jenkins 服务的用户的主目录。
In the latest version of git, had to use %GIT_HOME%/cmd/git.exe, rather than %GIT_HOME%/bin/git.exe and figuring out the home directory of the user running the jenkins service.
我遇到的另一个问题是,ssh.exe 没有在
%userprofile%/.ssh
文件夹中查找关键文件。相反,它会查找文件夹C:\Program Files (x86)\Git\.ssh
,该文件夹为空,并且由于 git repo 所在计算机上的 ssh 身份验证提示而导致挂起。我们只需将
%userprofile%/.ssh
下的关键文件复制到C:\Program Files (x86)\Git\.ssh
即可解决问题。Another issue i faced with was, ssh.exe was not looking at the
%userprofile%/.ssh
folder for the key files. Instead it was looking to the folderC:\Program Files (x86)\Git\.ssh
which was empty and which causes a hang due to ssh authentication prompt on the machine where git repo located.We just copied the key files under
%userprofile%/.ssh
toC:\Program Files (x86)\Git\.ssh
and the problem is resolved.来自惨痛教训的笔记。
我在让 ssh 作为 ssh+git 的指定用户帐户运行 Jenkins 时遇到问题。
这是我必须做的来解决问题:
我尝试使用 puttygen 和 GET_SSH=plink 都失败了,但没有明显的错误。
Notes from a hard learned lesson.
I had problems getting the ssh to work running Jenkins as a named user account for ssh+git.
Here is what I had to do to solve the problem:
I tried with puttygen and GET_SSH=plink that all failed very bad but no clear errors.
当您必须使用每用户配置文件中的任何配置选项时,例如。 ~/.ssh/config 可以放在 C:\Program Files (x86)\Git\etc\ssh\ssh_config 中,关键文件可以放在 C:\Program Files (x86)\Git.ssh 中
When you have to use any configuration options from a per-user configuration file eg. ~/.ssh/config you can put them in C:\Program Files (x86)\Git\etc\ssh\ssh_config, the key files can be put in C:\Program Files (x86)\Git.ssh
如果您的帐户附加到域。然后您需要确保运行 Jenkins Slave 的用户。为此,请打开“Jenkins Slave”的设置->属性->登录。并从域中选择必要的用户以正确执行。
If your account is attached to domain. Then you need to make sure user for which the Jenkins Slave is ran. For the purpose open Settings->Properties of "Jenkins Slave"->Log On. and choose necessary user from domain for correct execution.
由于我的 Windows Jenkins 是从属节点,因此我需要配置该节点以在 cmd 中查找 git,而不是按照 inger 描述的 bin 查找。为此,请转到“管理 Jenkins”、“管理节点”,单击相应的节点,单击“配置”,然后转到“工具位置”。在下拉列表中找到 git,然后指定 git.exe 的路径(包括 git.exe),例如 C:\Program Files\Git\cmd\git.exe。
我确认 cmd/git.exe 的工作方式与命令行中的 bin/git.exe 不同,并且使用 git 命令(而不是 scm 存储库)进行临时 jenkins 作业。
Since my Windows Jenkins was a slave, I needed to configure that node to find the git in cmd instead of bin as described by inger. To do this, go to Manage Jenkins, Manage Nodes, click on the appropriate node, click on Configure and then go to the Tool Locations. Find git in the drop-down and then specify the path to git.exe (including git.exe), like C:\Program Files\Git\cmd\git.exe.
I confirmed that the cmd/git.exe worked differently than the bin/git.exe from both command-line and with a temporary jenkins job using the git command (instead of an scm repo).
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
只需向 Jenkins 添加启用 ssh 的用户登录即可,它应该可以顺利运行。
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
Just add a ssh-enabled user logon to Jenkins and it should work smoothly.