Windows Server 2025上Jenkins跨流水线调用时无法克隆共享库
Jenkins流水线调用时Git仓库损坏错误排查
问题场景
在Windows Server 2025上将Jenkins作为服务运行,Jenkinsfile与共享库均存储于GitLab仓库。手动构建任意流水线均正常,但流水线A调用流水线B时出现Git仓库损坏的错误。
错误日志
Started by upstream project "Test" build number 14 originally caused by: Started by user <UserName> Loading library SharedLibTest@dev:libraries/ Attempting to resolve dev from remote references... > git.exe --version # timeout=10 > git --version # 'git version 2.53.0.windows.2' using GIT_ASKPASS to set credentials Jenkins token for GitLab access > git.exe ls-remote -h -- https://giturl/repo.git # timeout=10 Found match: refs/heads/dev revision b3efb5fbde73a1214ab44ff36dfc88b23a0217d6 Selected Git installation does not exist. Using Default The recommended git tool is: NONE using credential JenkinsGitLabToken > git.exe rev-parse --resolve-git-dir D:\h\workspace\RP@libs\4566a0d73a56c847d87178169741ab8291c61f3aad83825fd5ff8f285cbda243\.git # timeout=10 ERROR: Workspace has a .git repository, but it appears to be corrupt. hudson.plugins.git.GitException: Error performing git command: git.exe rev-parse --resolve-git-dir D:\h\workspace\RP@libs\4566a0d73a56c847d87178169741ab8291c61f3aad83825fd5ff8f285cbda243\.git at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2864) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2773) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2768) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2055) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2067) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.hasGitRepo(CliGitAPIImpl.java:407) at PluginClassLoader for git-client//hudson.plugins.git.GitAPI.hasGitRepo(GitAPI.java:283) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1205) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1310) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1277) at PluginClassLoader for workflow-scm-step//org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.lambda$doRetrieve$4(SCMBasedRetriever.java:200) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.retrySCMOperation(SCMBasedRetriever.java:222) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.doRetrieve(SCMBasedRetriever.java:199) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:79) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:297) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.LibraryAdder.add(LibraryAdder.java:156) at PluginClassLoader for pipeline-groovy-lib//org.jenkinsci.plugins.workflow.libs.LibraryDecorator$1.call(LibraryDecorator.java:125) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1087) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293) at PluginClassLoader for script-security//org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox$Scope.parse(GroovySandbox.java:162) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:202) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:186) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:670) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:616) at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:344) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:456) Caused by: java.io.IOException: Cannot run program "git.exe" (in directory "D:\h\workspace\RP@libs\4566a0d73a56c847d87178169741ab8291c61f3aad83825fd5ff8f285cbda243"): CreateProcess error=87, The parameter is incorrect
已尝试的解决方案
- 在
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem中启用Windows长路径 - 为Git启用长路径(执行
git config --global core.longpaths=true) - 将Jenkins主目录移至驱动器根目录以缩短路径
- 将流水线移至Jenkins根目录(无文件夹)以缩短路径
以上操作均未能解决问题。
环境信息
- Jenkins版本:2.555.1(最新版)
- Git插件版本:5.10.1(最新版)
- 操作系统:Windows Server 2025
- Git版本:2.53.0.windows.2
补充说明
手动执行对应Git命令(git.exe rev-parse --resolve-git-dir目标路径)无报错。
内容的提问来源于stack exchange,提问作者chewbap
相关产品推荐
相关产品推荐

