Jenkins多分支流水线Git Fetch超时,如何获取详细错误日志?
我在运行Jenkins的Windows 10机器上更新了Git版本,试图解决Git LFS新文件无法下载的问题。更新后,「Scan Multibranch Pipeline」执行git fetch时卡住,创建的本地缓存仓库始终只有25.7 KB(包含19个文件和9个文件夹),未下载任何远程文件。扫描流水线日志如下:
Started by user admin [Fri Jun 16 12:30:06 EDT 2023] Starting branch indexing... Creating git repository in C:\Program Files (x86)\Jenkins\caches\git-13907a292e8cd0afde55a9f2fc947755 > git init C:\Program Files (x86)\Jenkins\caches\git-13907a292e8cd0afde55a9f2fc947755 # timeout=10 Setting origin to https://github.com/[I have removed the rest of the URL] > git config remote.origin.url https://github.com/[I have removed the rest of the URL] # timeout=10 Fetching origin... Fetching upstream changes from origin > git --version # timeout=10 using GIT_ASKPASS to set credentials Git build credentials > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* ERROR: Timeout after 10 minutes ERROR: [Fri Jun 16 12:40:06 EDT 2023] Could not update folder level actions from source 55deb54e-a4bc-4990-8406-9b7cf00937fd hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" returned status code -1: stdout: stderr: at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1643) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:352) at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:344) at jenkins.plugins.git.AbstractGitSCMSource.retrieveActions(AbstractGitSCMSource.java:581) at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:746) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:591) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:276) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:978) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:419) [Fri Jun 16 12:40:06 EDT 2023] Finished branch indexing. Indexing took 10 min FATAL: Failed to recompute children of [My multibranch pipeline project] hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" returned status code -1: stdout: stderr: at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1643) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:352) at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:344) at jenkins.plugins.git.AbstractGitSCMSource.retrieveActions(AbstractGitSCMSource.java:581) at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:746) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:591) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:276) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:978) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:419) Finished: FAILURE
已尝试更换凭证,问题依旧。请问如何获取更多相关信息或日志?
提升Jenkins Git插件日志级别
进入Jenkins的「Manage Jenkins」→「System Log」→「Add new log recorder」,创建新日志记录器,添加以下类别并设置级别为FINEST:org.jenkinsci.plugins.gitclienthudson.plugins.git
重新触发分支扫描,日志会输出Git客户端执行的详细交互过程。
手动在Jenkins服务器执行Git命令
登录Windows 10机器,打开命令提示符,切换到Jenkins缓存仓库目录(C:\Program Files (x86)\Jenkins\caches\git-13907a292e8cd0afde55a9f2fc947755),执行:git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* --verbose--verbose参数会输出fetch的详细过程,可查看是否卡在特定对象下载、认证或LFS操作环节。同时执行git config --list确认LFS配置是否正确。配置Jenkins全局Git调试参数
进入「Manage Jenkins」→「Global Tool Configuration」→「Git」,在「Git executable」的「Additional behaviour」中添加参数,比如-c lfs.loglevel=debug,分支扫描时会传递该参数给Git,输出更多LFS相关日志。检查Windows系统事件日志
打开Windows「事件查看器」,查看「Windows日志」→「应用程序」中Git或Jenkins相关的错误/警告,排查系统层面问题(如权限、网络连接异常)。临时延长分支扫描超时时间
在多分支流水线配置中找到「Branch indexing」的超时设置,或在Git插件配置中调整命令超时。若fetch能完成,可查看完整执行日志;若仍卡住,可排除临时网络波动因素。
内容的提问来源于stack exchange,提问作者Allen Pestaluky

