【问题标题】:Jenkins hanging at "Fetching upstream changes from origin"詹金斯挂在“从原点获取上游更改”上
【发布时间】:2013-03-20 11:08:27
【问题描述】:

我正在尝试在 Windows Server 2012 机器上设置 Jenkins,但遇到了很多困难。

我做过的事情:

  • 创建了无密码id_rsaid_rsa.pub
  • 使用ssh.exe -T bitbucket.org 为bitbucket.org 创建了known_hosts 文件并接受添加主机。
  • 已将E: 添加到系统范围的 HOME 变量中
  • 我已将这些文件添加到 C:/Windows/SysWOW64/config/systemprofile/.sshE:/.ssh
  • 我已将我的公钥作为部署密钥链接到 Bitbucket。
  • 我已经检查了我所有的 URL、用户名等。
  • 我什至手动从存储库中拉出以在C:/Program Files (x86)/Jenkins/jobs/MyProject/workspace/ 中设置初始基础

但它仍然挂在

Building in workspace C:\Program Files (x86)\Jenkins\jobs\MyProject\workspace
Checkout:workspace / C:\Program Files (x86)\Jenkins\jobs\MyProject\workspace - hudson.remoting.LocalChannel@13ca972
Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin

我给了它大约 20 分钟,所以这不是回购问题的速度/大小。如果我取消,这就是返回的内容:

ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Error performing command: C:\Program Files     (x86)\Git\bin\git.exe fetch -t origin +refs/heads/*:refs/remotes/origin/*
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:780)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:739)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.fetch(CliGitAPIImpl.java:160)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:230)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:793)
at hudson.plugins.git.GitSCM.access$000(GitSCM.java:57)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:976)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
at hudson.FilePath.act(FilePath.java:865)
at hudson.FilePath.act(FilePath.java:838)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1364)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:670)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:575)
at hudson.model.Run.execute(Run.java:1575)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(Native Method)
at hudson.Proc$LocalProc.join(Proc.java:319)
at hudson.Launcher$ProcStarter.join(Launcher.java:360)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:769)
... 19 more
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:981)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
at hudson.FilePath.act(FilePath.java:865)
at hudson.FilePath.act(FilePath.java:838)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1364)
at     hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:670)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:575)
at hudson.model.Run.execute(Run.java:1575)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)

我在这里束手无策,所以我很感激我能得到的所有帮助。 以下是我尝试过的几篇文章,没有任何改进。

Authenticate Jenkins CI for Github private repository

Permission denied (publickey) when setting up Jenkins

Hudson Git Plugin not working on windows

http://computercamp.cdwilson.us/jenkins-git-clone-via-ssh-on-windows-7-x64

【问题讨论】:

标签: git ssh jenkins


【解决方案1】:

这是我解决类似问题的方法:

Msysgit 安装了两个git.exe。一个在C:\Program Files (x86)\Git\bin 下,另一个在C:\Program Files (x86)\Git\cmd 下。第一个不能与 Jenkins 一起使用。它会在完成它的工作后挂起。第二个效果很好。

更新您的 Jenkins Git 设置以指向正确的 cmd\git.exe 并享受吧!

【讨论】:

  • 谢谢!像魅力一样工作。
【解决方案2】:

我就是这样解决的:

我运行 sysinternals 工具 psexec 来生成在 LocalSystem 帐户下运行的 CMD(与 jenkins 服务相同的帐户正在运行)

PSEXEC -i -s -d CMD

在这个 cmd 提示符下,我从工作区目录执行了与挂起的 GIT.exe 进程相同的 git 命令。例如。

d:\Programs\Jenkins\jobs\jobname\workspace>D:\Programs\Git\bin\git.exe fetch -t ssh+git://gitpub@my.server.com:9360/data/gitpub /myRepository.git +refs/heads/:refs/remotes/origin/

瞧:我被提示输入“是”以将 SSH 密钥添加到已知主机的已知列表中。

【讨论】:

    【解决方案3】:

    您也可以体验一下“从原点获取上游更改”的冻结。

    在基于 Windows 的机器上将 Jenkins 作为服务运行似乎(根据我的经验)在使用 SSL 时会出现问题。

    解决方法]

    1. 更改您的 Jenkins 服务以在本地帐户下运行。
    2. 确保您的本地管理员帐户配置为使用 SSH 执行 Git 交互。
    3. 重启 Jenkins (details)。
    4. 如果 Jenkins 没有启动,它在尝试从 Git 中提取时会出现问题。手动终止 git 和 ssh 进程,从 Jenkins 中终止您的 java.exe 并手动启动 Jenkins 服务。

    我为何选择此解决方案的详细信息]

    在设置授权主机以接受服务器并在服务器上注册 Jenkins 密钥以允许连接之前,我已遵循其他步骤。我已经确保我可以在我的本地系统帐户(运行 Jenkins 服务)下成功执行 Git 操作。尽管如此,提取仍会冻结。为了检查我的 Git 和 SSL 配置是否正确,我什至去了我的 Jenkins 作业目录中最初配置的 Git 存储库,并成功执行了拉取请求 under the local system account。有效;因此密钥已正确设置。

    我忘记了我在哪里看到的,但我听说在本地系统下处理 Git/SSH 时会出现问题。有了这些知识,我使用了我的 Git 环境并更改了 GIT_SSH 环境变量以使用plink (结合使用 Putty 来记住服务器密钥,使用 puttygen 将 OpenSSL 密钥转换为 Putty 密钥和选美来记住我的密钥)为 plink。一旦我让它与 plink 一起工作,我发现它不是一个可用的解决方案。为了正确使用 plink,我还必须在我的本地系统帐户下运行 pageant 才能让 Jenkins 服务正确协商 SSH 调用。在考虑了如何在重新启动时正确设置我的初始状态后,我不想把所有这些精力都花在让 SSH 连接正常工作上。

    相反,我决定在我的本地管理员帐户下运行 Jenkins 更容易,该帐户也被配置为处理 Git 服务器。无需为本地系统帐户处理已配置的 SSH 密钥,我的 git 操作运行良好。


    请注意,David Gageot 的回答可能适用于某些人。我不必更改任何 Git 设置,因为在安装 Git 时,我选择了选项 Run Git from the Windows Command Prompt,它将路径映射到 C:\Program Files (x86)\Git\bin\cmd\ 目录。

    【讨论】:

      【解决方案4】:

      在 Windows 上配置 jenkins 时,我发现另一个非常有用的链接,尤其是在使用 MSI 安装程序时:http://opensourcetester.co.uk/2013/06/28/jenkins-windows-ssh/

      还有一件我没有发现明显的事情是:连接到 Github 时必须使用 SSH url 而不是默认的 https 。希望这会为某人节省时间。

      【讨论】:

        【解决方案5】:

        我的笔记本电脑上遇到了同样的问题,我找到了解决方案,但这仅适用于在设置为 Windows 服务的 Tomcat Web 容器中运行 Jenkins 战争的情况。

        我只需要将 Tomcat 服务设置为以我的 Windows 用户而不是本地系统用户身份登录。

        【讨论】:

          【解决方案6】:

          对我来说是 $HOME/.ssh 文件夹及其内容的权限。将其设置为对特定用户组可见后,Jenkins 能够在重新启动后获取更改。

          【讨论】:

            【解决方案7】:

            Version 2.6.1 of the Git client for Windows 在 Jenkins 中修复了这个问题。现在“从原点获取上游更改”没有任何延迟。

            我在 Jenkins 中使用 git cmd 来自:

            C:\Program Files\Git\cmd\git.exe

            【讨论】:

              【解决方案8】:

              我花了几个小时试图解决这个问题,我发现将密码添加到 repo URL 解决了这个问题:

              https://USERNAME:PASSWORD@bitbucket.org/REPO.git
              

              请注意用户名和密码之间的:

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 2021-09-12
                • 2013-07-16
                • 2021-01-22
                • 1970-01-01
                • 2021-09-03
                • 1970-01-01
                • 2016-07-16
                相关资源
                最近更新 更多