Jenkins卡在“从源获取上游更改”的阶段。

31
我正在尝试在Windows Server 2012机器上设置Jenkins,但是遇到了很多困难。
我已经完成以下操作:
- 创建了一个无需密码的id_rsa和id_rsa.pub - 使用ssh.exe -T bitbucket.org创建了一个known_hosts文件,并同意添加主机。 - 将E:添加到系统范围内的HOME变量中 - 我已将这些文件添加到C:/Windows/SysWOW64/config/systemprofile/.ssh以及E:/.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)

我在这里感到非常无助,非常感谢您提供的帮助。 以下是一些我已经尝试但没有改善的文章。

为Github私有存储库验证Jenkins CI身份

设置Jenkins时出现权限拒绝(publickey)

Hudson Git插件在Windows上无法工作

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


这是路径问题吗?(http://blog.cgdecker.com/2011/02/git-clone-error-on-jenkinshudson-on.html) - VonC
在 Jenkins 的运行实例中再次确认 HOME(例如 http://blog.hlyh.dk/2011/07/debugging-hudson-git-plugin-hanging.html)。 - VonC
我也遇到了这个问题。令人沮丧的是,有时它能正常工作,有时却不能。所以一切都必须正确配置,但它只是随机失败。 - Josh Santangelo
8个回答

31

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

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

更新您Jenkins Git设置,指向正确的cmd\git.exe,然后享受!


谢谢!运行得非常顺利。 - GDefender

8
这是我的解决方法:
我使用sysinternals工具psexec来生成一个CMD窗口,该窗口在LocalSystem帐户下运行(与jenkins服务运行的帐户相同)。
PSEXEC -i -s -d 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/ 然后,我被提示输入“yes”将SSH密钥添加到已知主机列表中。

2

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

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


2

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

还有一件事情不太明显,就是连接到Github时必须使用SSH URL而不是默认的https URL。希望这能为某些人节省时间。


2

我也遇到了“从源获取上游更改”时的冻结问题。

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

解决方法:

  1. 将Jenkins服务更改为以本地帐户运行。
  2. 确保您的本地管理员帐户已配置为使用SSH与Git交互。
  3. 重启Jenkins (详情)。
  4. 如果Jenkins无法启动,则尝试从Git拉取时出现问题。手动终止git和ssh进程,关闭Jenkins中的java.exe并手动启动Jenkins服务。

选择此解决方案的原因:

我之前采取了其他步骤,设置授权主机以接受服务器并在服务器上注册Jenkins密钥以允许连接。我确保我可以在我的本地系统帐户下成功执行Git操作(Jenkins服务运行在该帐户下)。但是,获取操作仍然会冻结。为了检查我的Git和SSL是否正确配置,我甚至去了Jenkins工作目录中最初配置的Git存储库,并在本地系统帐户下成功执行了拉取请求。它可以工作,因此密钥已正确设置。

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

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


请注意,David Gageot的答案可能适用于某些情况。当我安装Git时,我选择了选项从Windows命令提示符中运行Git,它将路径映射到C:\ Program Files(x86)\ Git \ bin \ cmd \ 目录。


1

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


0

Windows版Git客户端2.6.1版本修复了Jenkins中的这个问题。现在,“从源获取上游更改”没有延迟。

我正在使用Jenkins中的git cmd,路径为:

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


0

我花了几个小时来解决这个问题,最终发现将密码添加到仓库URL中可以解决问题:

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

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接