Jenkins git fetch超时

18

我正在工作的Mac OS X Mavericks电脑上运行Jenkins 2.0。我正试图从内部服务器拉取一个存储库。但是,作业在git fetch调用上挂起10分钟,然后超时。

如果我从shell脚本(从Jenkins中)手动运行git clonegit fetch,我会得到相同的总体结果,只是作业无限挂起。

我可以从终端运行clonefetch命令。

我想知道是否这是一些需要解决的用户权限错误。

这是日志:

Started by user Colin Basnett
Building in workspace /Users/Shared/Jenkins/Home/workspace/Service
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url http://192.168.4.40/Bonobo.Git.Server/Service.git # timeout=10
Fetching upstream changes from http://192.168.4.40/Bonobo.Git.Server/Service.git
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username jenkins # timeout=10
 > git config --local credential.helper store --file=/Users/Shared/Jenkins/tmp/git8010092725741498465.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress http://192.168.4.40/Bonobo.Git.Server/Service.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from http://192.168.4.40/Bonobo.Git.Server/Service.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:766)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1022)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1053)
    at hudson.scm.SCM.checkout(SCM.java:485)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress http://192.168.4.40/Bonobo.Git.Server/Service.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: Authentication failed for 'http://192.168.4.40/Bonobo.Git.Server/Service.git/'

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:764)
    ... 11 more
ERROR: null
Finished: FAILURE

非常感谢您提前提供的任何帮助。


2
根据日志,git命令设置了选项core.askpass=true。因此,git正在等待一个从未给出的密码。 - Frodon
1
我看到日志中出现了错误:“fatal: Authentication failed for 'http://192.168.4.40/Bonobo.Git.Server/Service.git/'”,可能需要先检查Jenkins git配置。对于我来说,设置Jenkins git配置的路径是:管理Jenkins - 配置系统 - Gitlab(因为我们使用的是gitlab服务器)- 凭据 - MadHatter
1个回答

30

对我来说,这只是一个短暂的超时。在您的情况下,您可能需要执行以下操作:

  1. 增加克隆和检出的超时时间
    1. 转到作业配置并查找Git部分
    2. 添加->高级克隆行为。 在那里,您可以指定超时时间并选择“浅层复制”(速度更快)
    3. 添加->高级检出行为。 您可以设置检出的超时时间。
  2. 确保在作业配置-源代码管理-Git-Credentials中提供了正确的凭据

1
嘿,谢谢!我为这个问题苦恼了两天。 我使用Bitbucket文件夹、流水线和自动构建PRs。你的建议帮助我解决了这个问题:ERROR: Error fetching remote repo 'origin' - approximatenumber
1
默认超时值(10分钟)有点令人困惑(我希望看到的是十秒钟之类的)。无论如何,当GitHub连接不稳定时,浅层模式确实非常有用。 - Nikita Bosik
之前不知道还有浅拷贝这个方法。使用它可以显著提高结账流程的速度。 - chrmue

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