git 詹金斯挂在“从源头获取上游更改”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15708490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins hanging at "Fetching upstream changes from origin"
提问by DTI-Matt
I'm trying to set up Jenkins on a Windows Server 2012 machine, and I'm having a lot of difficulty.
我正在尝试在 Windows Server 2012 机器上设置 Jenkins,但遇到了很多困难。
Things I've done:
我做过的事情:
- Created a password-less
id_rsa
, andid_rsa.pub
- Created a
known_hosts
file for bitbucket.org usingssh.exe -T bitbucket.org
and accepting to add the host. - Added
E:
to System-wide HOME Variable - I've added those files to
C:/Windows/SysWOW64/config/systemprofile/.ssh
as well asE:/.ssh
- I've linked my public key to Bitbucket as a deployment key.
- I've triple-checked all my URLs, usernames, etc.
- I've even manually pulled from the repository to setup an initial base in
C:/Program Files (x86)/Jenkins/jobs/MyProject/workspace/
- 创建了一个无密码的
id_rsa
,和id_rsa.pub
known_hosts
使用ssh.exe -T bitbucket.org
并接受添加主机为 bitbucket.org创建了一个文件。- 添加
E:
到系统范围的 HOME 变量 - 我已经添加了这些文件
C:/Windows/SysWOW64/config/systemprofile/.ssh
,以及E:/.ssh
- 我已将我的公钥链接到 Bitbucket 作为部署密钥。
- 我已经三重检查了我所有的 URL、用户名等。
- 我什至手动从存储库中提取以在
C:/Program Files (x86)/Jenkins/jobs/MyProject/workspace/
And yet it still hangs at
然而它仍然挂在
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
I've given it about 20 minutes, so it's not a speed / size of the repo issue. If I cancel, this is what is returned:
我给了它大约 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.accessPSEXEC -i -s -d CMD
0(GitSCM.java:57)
at hudson.plugins.git.GitSCM.invoke(GitSCM.java:976)
at hudson.plugins.git.GitSCM.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.invoke(GitSCM.java:981)
at hudson.plugins.git.GitSCM.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)
I'm at my wits end here, so I appreciate all the help I can get. Here are a choice few articles which I've tried with no improvement.
我在这里不知所措,所以我很感激我能得到的所有帮助。这里有一些我尝试过但没有改进的文章。
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
http://computercamp.cdwilson.us/jenkins-git-clone-via-ssh-on-windows-7-x64
回答by David Gageot
Here's how I fixed a similar issue:
以下是我解决类似问题的方法:
Msysgit installs two git.exe
. One under C:\Program Files (x86)\Git\bin
and a second one under C:\Program Files (x86)\Git\cmd
. The first one cannot be used with Jenkins. It will hang after completing it's job. The second one works perfectly.
Msysgit 安装两个git.exe
. 一个下C:\Program Files (x86)\Git\bin
一个第二个下C:\Program Files (x86)\Git\cmd
。第一个不能与 Jenkins 一起使用。完成工作后它会挂起。第二个完美运行。
Update your Jenkins Git settings to point to the correct cmd\git.exe
and enjoy!
更新您的 Jenkins Git 设置以指向正确的cmd\git.exe
并享受!
回答by Andreas
This is how I solved it:
我是这样解决的:
I ran the sysinternals tool psexec to spawn a CMD which is running under the LocalSystem account (same account like jenkins service is running)
我运行了 sysinternals 工具 psexec 来生成一个在 LocalSystem 帐户下运行的 CMD(与 jenkins 服务运行的帐户相同)
https://USERNAME:[email protected]/REPO.git
In this cmd prompt I executed the same git command from the workspace directory as the hanging GIT.exe processes do. E.g.
在这个 cmd 提示中,我从工作区目录执行了与挂起的 GIT.exe 进程相同的 git 命令。例如
d:\Programs\Jenkins\jobs\jobname\workspace>D:\Programs\Git\bin\git.exe fetch -t ssh+git://[email protected]:9360/data/gitpub/myRepository.git +refs/heads/:refs/remotes/origin/
d:\Programs\Jenkins\jobs\jobname\workspace>D:\Programs\Git\bin\git.exe fetch -t ssh+git://[email protected]:9360/data/gitpub/myRepository. git +refs/heads/ :refs/remotes/origin/
Et voila: I was prompted to enter "yes" to add the SSH key to the known list of known hosts.
等等:系统提示我输入“是”以将 SSH 密钥添加到已知主机的已知列表中。
回答by jdknight
Just experience the freeze at 'Fetching upstream changes from origin' as well.
只需体验“从原点获取上游更改”的冻结。
Running Jenkins as a service on a Windows based machine seems to (from what I have experienced) to have issues when using SSL.
在基于 Windows 的机器上将 Jenkins 作为服务运行似乎(根据我的经验)在使用 SSL 时出现问题。
Workaround Solution]
变通方法解决方案]
- Alter your Jenkins service to run under a local account.
- Ensure your local administrator account is configured to perform Git interaction with SSH.
- Restart Jenkins (details).
- If Jenkins does not start, it had issues trying to pull from Git. Manually kill git and ssh processes, kill your java.exe from Jenkins and manually start the Jenkins service.
- 更改您的 Jenkins 服务以在本地帐户下运行。
- 确保您的本地管理员帐户已配置为使用 SSH 执行 Git 交互。
- 重启詹金斯(详情)。
- 如果 Jenkins 没有启动,它在尝试从 Git 中提取时会出现问题。手动杀死 git 和 ssh 进程,从 Jenkins 中杀死你的 java.exe 并手动启动 Jenkins 服务。
Details on Why I Choose this Solution]
关于我为什么选择此解决方案的详细信息]
I have followed other steps before with setting up the authorized host to accept the server and registering the Jenkins' key on the server to permit the connection. I've made sure I could successfully perform Git actions under my Local System account (which the Jenkins service was run under). Still, the fetch would freeze. To check that my Git and SSL was configured correctly, I even went to the initially configured Git repository in my Jenkins jobs directory and performed a successfully pull request under the local system account. It worked; therefore the keys have been setup correctly.
在设置授权主机以接受服务器并在服务器上注册 Jenkins 的密钥以允许连接之前,我已经遵循了其他步骤。我确保我可以在我的本地系统帐户(Jenkins 服务在其下运行)下成功执行 Git 操作。尽管如此,提取还是会冻结。为了检查我的 Git 和 SSL 是否配置正确,我什至转到了 Jenkins 作业目录中最初配置的 Git 存储库,并在本地系统帐户下成功执行了拉取请求。有效; 因此密钥已正确设置。
I forgot where I read this, but I heard issues arise when dealing with Git/SSH under a local system. With this knowledge, I played with my Git environment and altered the GIT_SSH environment variable to use plink (with a combination of Putty to remember the server key, puttygen to convert an OpenSSL key to a Putty key and pageant to remember my keys) for plink. Once I got it working with plink, I did not find it to be a useable solution. I order to correctly use plink, I had to also run pageant under my local system account to have the Jenkins service correctly negotiate SSH calls. After thinking how I would correctly setup my initial state on reboot, I didn't want to put all this effort into just getting the SSH connection working.
我忘了我在哪里读到的,但我听说在本地系统下处理 Git/SSH 时会出现问题。有了这些知识,我玩了我的 Git 环境并更改了 GIT_SSH 环境变量以使用plink(结合 Putty 来记住服务器密钥,puttygen 将 OpenSSL 密钥转换为 Putty 密钥和选美来记住我的密钥)用于 plink . 一旦我让它与 plink 一起工作,我就没有发现它是一个可用的解决方案。为了正确使用 plink,我还必须在我的本地系统帐户下运行 pageant 才能让 Jenkins 服务正确协商 SSH 调用。在考虑如何正确设置重启时的初始状态后,我不想把所有这些努力都放在让 SSH 连接正常工作上。
Instead, I decided it was easier to just run Jenkins under my local administrator account which was also configured to deal with the Git server. No having to deal with configured SSH keys for the local system account and my git actions worked fine.
相反,我决定在我的本地管理员帐户下运行 Jenkins 更容易,该帐户也被配置为处理 Git 服务器。无需处理为本地系统帐户配置的 SSH 密钥,我的 git 操作运行良好。
Note, David Gageot's answer can apply to some. I did not have to alter any of my Git settings as when I installed Git, I choose the option Run Git from the Windows Command Prompt
which maps a path to the C:\Program Files (x86)\Git\bin\cmd\
directory.
请注意,David Gageot 的回答可能适用于某些人。在安装 Git 时,我不必更改任何 Git 设置,我选择了Run Git from the Windows Command Prompt
将路径映射到C:\Program Files (x86)\Git\bin\cmd\
目录的选项。
回答by Woland
Another link that I found very helpful when configuring jenkins on windows, especially when using the MSI installer is this: http://opensourcetester.co.uk/2013/06/28/jenkins-windows-ssh/
我发现在 Windows 上配置 jenkins 时非常有用的另一个链接是:http: //opensourcetester.co.uk/2013/06/28/jenkins-windows-ssh/
And one more thing that I didn't find obvious was: you have to use SSH url when connecting to Github instead of default https one. Hopefully that will save time to someone.
我没有发现的另一件事是:连接到 Github 时必须使用 SSH url 而不是默认的 https url。希望这会为某人节省时间。
回答by Sheparzo
I had this same issue on my laptop and I was able to figure out a solution, however this really only applies if you are running the Jenkins war in a Tomcat web container that is setup as a Windows service.
我在我的笔记本电脑上遇到了同样的问题,我能够找到一个解决方案,但是这实际上只适用于在设置为 Windows 服务的 Tomcat Web 容器中运行 Jenkins war 的情况。
I just had to set the Tomcat service to logon as my windows user instead of Local System.
我只需要将 Tomcat 服务设置为以我的 Windows 用户身份登录,而不是本地系统。
回答by martoncsukas
For me it was the permissions on the $HOME/.ssh folder and its content. After setting it visible for the specific user group, Jenkins was able to fetch the changes after a restart.
对我来说,它是对 $HOME/.ssh 文件夹及其内容的权限。将其设置为对特定用户组可见后,Jenkins 能够在重新启动后获取更改。
回答by Thomas T
Version 2.6.1 of the Git client for Windowsfixes this problem in Jenkins. Now “Fetching upstream changes from origin” has no delay.
适用于 Windows 的 Git 客户端 2.6.1 版在 Jenkins 中修复了此问题。现在“从原点获取上游更改”没有延迟。
I am using the git cmd in Jenkins from:
我在 Jenkins 中使用 git cmd 来自:
C:\Program Files\Git\cmd\git.exe
C:\Program Files\Git\cmd\git.exe
回答by IndieTech Solutions
I spent few hours trying to figure this out and I found out that adding the password to the repo URL fixed the issue:
我花了几个小时试图弄清楚这一点,我发现将密码添加到 repo URL 解决了这个问题:
##代码##Please note the :between username and password
请注意:在用户名和密码之间