Jenkins 无法在 Windows 上通过 Git/SSH 克隆 Git 存储库

发布于 2024-12-11 03:09:31 字数 2611 浏览 0 评论 0原文

我已经在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

非要怀念 2024-12-18 03:09:31

我最近经历了这些痛苦。尤其令人沮丧的是在这种情况下缺少错误日志:可能是因为 MSysgit 在尝试恢复时在控制台上提示用户 - 这不会通过 Jenkins 控制台。

根据我的经验,这里有一些需要注意的关键要素:

  1. 同时安装了 Msysgit 和 Cygwin:MSysgit 对我来说效果更好 - 但我假设你也在使用它,
  2. 有些人在 方面运气更好;\cmd\git.cmd\bin\git.exe
  3. 确保您的从服务器以同一用户运行(这不是默认用户)基于服务的安装).. - 哦,我看到你也
  4. 明确地为 Windows 从站设置 HOME 变量,
  5. 基本上确保在 Jenkins 下达到相同的 .ssh 密钥。
  6. 为了调试,我发现创建一个没有 SCM 的测试作业很有用,但在“执行 shell/批处理”构建步骤中运行 git clone 。这应该会透露更多信息。顺便说一句,您可以在同一步骤中执行 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:

  1. a mix of both Msysgit and Cygwin installed: MSysgit worked better for me- but I assume you're using that too
  2. some people have more luck with <MSYSGIT_ROOT>\cmd\git.cmd than <MSYSGIT_ROOT>\bin\git.exe
  3. 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
  4. setting HOME variable for windows slaves explicity
  5. basically make sure the same .ssh keys are reached when under Jenkins.
  6. 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 an env in the same step and maybe ls %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!

毁虫ゝ 2024-12-18 03:09:31

在最新版本的 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.

为你鎻心 2024-12-18 03:09:31

我遇到的另一个问题是,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 folder C:\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 to C:\Program Files (x86)\Git\.ssh and the problem is resolved.

紫轩蝶泪 2024-12-18 03:09:31

来自惨痛教训的笔记。
我在让 ssh 作为 ssh+git 的指定用户帐户运行 Jenkins 时遇到问题。

这是我必须做的来解决问题:

  1. 使用 ssh-keygen 生成密钥(注意它们所在的位置)
  2. 将“HOME”设置为这个位置

我尝试使用 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:

  1. Generate the key using ssh-keygen (note where they are located)
  2. Set "HOME" to this location

I tried with puttygen and GET_SSH=plink that all failed very bad but no clear errors.

爱的十字路口 2024-12-18 03:09:31

当您必须使用每用户配置文件中的任何配置选项时,例如。 ~/.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

爱人如己 2024-12-18 03:09:31

如果您的帐户附加到域。然后您需要确保运行 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.

或十年 2024-12-18 03:09:31

由于我的 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).

時窥 2024-12-18 03:09:31

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文