最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

TeamCity fails to build project with error 'git fetch' command failed - Stack Overflow

programmeradmin2浏览0评论

Recently I have had this following issue when I create a new project in TeamCity:

Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: ".git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: ".git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
  exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895419, exit value: 1
  exit code: -1
  Repository sources transferred (748 B)
Will repeat attempt when server will be available, number of attempts left: 1
Updating sources: auto checkout (on server)
  Will use server side checkout: No supported VCS client found on the agent for vcs root '.git#refs/heads/main'. Details: Unable to run Git at path /usr/bin/git: /usr/bin/git version command failed.
  exit code: -1
  exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/bin/git" (in directory "."): error=0, Failed to exec spawn helper: pid: 895394, exit value: 1
  Building and caching clean patch for VCS root: .git#refs/heads/main
  Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: ".git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: ".git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
  exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895428, exit value: 1
  exit code: -1
  Repository sources transferred (748 B)
Patch is broken, can be found in file: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/buildTmp/temp9967238314985330842patch_3614
jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl$1: Server was not able to build correct patch, most likely due to VCS errors
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.throwError(PatchDownloaderImpl.java:156)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatch(PatchDownloaderImpl.java:146)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.copyPatchAndCheckFile(PatchDownloaderImpl.java:78)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.copyPatchAndCheck(PatchDownloaderImpl.java:98)
  at jetbrains.buildServer.agent.impl.patch.UpdateSourcesPatcherBase.copyPatchToTempFile(UpdateSourcesPatcherBase.java:65)
  at jetbrains.buildServer.agent.impl.patch.UpdateSourcesFromServer.updateSources(UpdateSourcesFromServer.java:45)
  at jetbrains.buildServer.agent.impl.patch.AbstractSourcesUpdater.doSourceUpdate(AbstractSourcesUpdater.java:52)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage$CheckoutAction.checkout(CheckoutSourcesBuildStage.java:116)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage$1.checkout(CheckoutSourcesBuildStage.java:65)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage.doCheckout(CheckoutSourcesBuildStage.java:81)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage.doRecoverableStage(CheckoutSourcesBuildStage.java:61)
  at jetbrains.buildServer.agent.impl.buildStages.startStages.RecoverableBuildStage.doLastAttempt(RecoverableBuildStage.java:114)
  at jetbrains.buildServer.agent.impl.buildStages.startStages.RecoverableBuildStage.doBuildStage(RecoverableBuildStage.java:72)
  at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:33)
  at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:24)
  at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:76)
  at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:35)
  at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor.doStages(BuildStagesExecutor.java:24)
  at jetbrains.buildServer.agent.impl.BuildRunActionImpl.doStages(BuildRunActionImpl.java:97)
  at jetbrains.buildServer.agent.AgentOperationModeEx.executeRunnerStages(AgentOperationModeEx.java:47)
  at jetbrains.buildServer.agent.impl.BuildRunActionImpl.runBuild(BuildRunActionImpl.java:68)
  at jetbrains.buildServer.agent.impl.BuildAgentImpl.doActualBuild(BuildAgentImpl.java:350)
  at jetbrains.buildServer.agent.impl.BuildAgentImpl.access$100(BuildAgentImpl.java:62)
  at jetbrains.buildServer.agent.impl.BuildAgentImpl$1.run(BuildAgentImpl.java:299)
  at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: jetbrains.buildServer.vcs.patches.UnsuccessfulPatchException: Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: ".git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: ".git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895428, exit value: 1
exit code: -1
  at jetbrains.buildServer.vcs.patches.AbstractPatcher$1.fail(AbstractPatcher.java:103)
  at jetbrains.buildServer.vcs.patches.LowLevelPatcher.readPatchStream(LowLevelPatcher.java:186)
  at jetbrains.buildServer.vcs.patches.LowLevelPatcher.applyPatch(LowLevelPatcher.java:105)
  at jetbrains.buildServer.vcs.patches.AbstractPatcher.applyPatch(AbstractPatcher.java:43)
  at jetbrains.buildServer.agent.impl.patch.PatchApplierImpl.applyPatch(PatchApplierImpl.java:19)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatchInFileIsCompleted(PatchDownloaderImpl.java:108)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatch(PatchDownloaderImpl.java:136)
  ... 23 more
Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: ".git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: ".git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895428, exit value: 1
exit code: -1
Publishing artifacts
  Collecting files to publish: [/home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/agentTmp/build_stages.txt=>.teamcity/perfmon/]
Publishing 1 file using [WebPublisher]: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/agentTmp/build_stages.txt => .teamcity/perfmon
Publishing 1 file using [ArtifactsCachePublisherImpl]: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/agentTmp/build_stages.txt => .teamcity/perfmon
Publishing artifacts
  Collecting files to publish: [/home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/buildTmp/.teamcity/docker/build_1/events.json => .teamcity/docker/]
Publishing internal artifacts
Publishing 1 file using [WebPublisher]
Publishing 1 file using [WebPublisher]: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/buildTmp/.teamcity/docker/build_1/events.json => .teamcity/docker

I have tried removing /root/.BuildServer/system/caches, but it does not work.

I suspect the agent does not have permission to run git fetch in the teamcity data.

TeamCity info:

  • Version: 2024.12.2 (build 174504)
  • OS: Ubuntu 24.04
  • Git is available in /usr/bin.

Any solutions please ?

Thanks,

Recently I have had this following issue when I create a new project in TeamCity:

Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: "https://gitlab/my-repo/my-repo.git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: "https://gitlab/my-repo/my-repo.git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
  exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895419, exit value: 1
  exit code: -1
  Repository sources transferred (748 B)
Will repeat attempt when server will be available, number of attempts left: 1
Updating sources: auto checkout (on server)
  Will use server side checkout: No supported VCS client found on the agent for vcs root 'https://gitlab/my-repo/my-repo.git#refs/heads/main'. Details: Unable to run Git at path /usr/bin/git: /usr/bin/git version command failed.
  exit code: -1
  exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/bin/git" (in directory "."): error=0, Failed to exec spawn helper: pid: 895394, exit value: 1
  Building and caching clean patch for VCS root: https://gitlab/my-repo/my-repo.git#refs/heads/main
  Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: "https://gitlab/my-repo/my-repo.git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: "https://gitlab/my-repo/my-repo.git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
  exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895428, exit value: 1
  exit code: -1
  Repository sources transferred (748 B)
Patch is broken, can be found in file: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/buildTmp/temp9967238314985330842patch_3614
jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl$1: Server was not able to build correct patch, most likely due to VCS errors
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.throwError(PatchDownloaderImpl.java:156)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatch(PatchDownloaderImpl.java:146)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.copyPatchAndCheckFile(PatchDownloaderImpl.java:78)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.copyPatchAndCheck(PatchDownloaderImpl.java:98)
  at jetbrains.buildServer.agent.impl.patch.UpdateSourcesPatcherBase.copyPatchToTempFile(UpdateSourcesPatcherBase.java:65)
  at jetbrains.buildServer.agent.impl.patch.UpdateSourcesFromServer.updateSources(UpdateSourcesFromServer.java:45)
  at jetbrains.buildServer.agent.impl.patch.AbstractSourcesUpdater.doSourceUpdate(AbstractSourcesUpdater.java:52)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage$CheckoutAction.checkout(CheckoutSourcesBuildStage.java:116)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage$1.checkout(CheckoutSourcesBuildStage.java:65)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage.doCheckout(CheckoutSourcesBuildStage.java:81)
  at jetbrains.buildServer.agent.impl.patch.CheckoutSourcesBuildStage.doRecoverableStage(CheckoutSourcesBuildStage.java:61)
  at jetbrains.buildServer.agent.impl.buildStages.startStages.RecoverableBuildStage.doLastAttempt(RecoverableBuildStage.java:114)
  at jetbrains.buildServer.agent.impl.buildStages.startStages.RecoverableBuildStage.doBuildStage(RecoverableBuildStage.java:72)
  at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:33)
  at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:24)
  at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:76)
  at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:35)
  at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor.doStages(BuildStagesExecutor.java:24)
  at jetbrains.buildServer.agent.impl.BuildRunActionImpl.doStages(BuildRunActionImpl.java:97)
  at jetbrains.buildServer.agent.AgentOperationModeEx.executeRunnerStages(AgentOperationModeEx.java:47)
  at jetbrains.buildServer.agent.impl.BuildRunActionImpl.runBuild(BuildRunActionImpl.java:68)
  at jetbrains.buildServer.agent.impl.BuildAgentImpl.doActualBuild(BuildAgentImpl.java:350)
  at jetbrains.buildServer.agent.impl.BuildAgentImpl.access$100(BuildAgentImpl.java:62)
  at jetbrains.buildServer.agent.impl.BuildAgentImpl$1.run(BuildAgentImpl.java:299)
  at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: jetbrains.buildServer.vcs.patches.UnsuccessfulPatchException: Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: "https://gitlab/my-repo/my-repo.git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: "https://gitlab/my-repo/my-repo.git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895428, exit value: 1
exit code: -1
  at jetbrains.buildServer.vcs.patches.AbstractPatcher$1.fail(AbstractPatcher.java:103)
  at jetbrains.buildServer.vcs.patches.LowLevelPatcher.readPatchStream(LowLevelPatcher.java:186)
  at jetbrains.buildServer.vcs.patches.LowLevelPatcher.applyPatch(LowLevelPatcher.java:105)
  at jetbrains.buildServer.vcs.patches.AbstractPatcher.applyPatch(AbstractPatcher.java:43)
  at jetbrains.buildServer.agent.impl.patch.PatchApplierImpl.applyPatch(PatchApplierImpl.java:19)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatchInFileIsCompleted(PatchDownloaderImpl.java:108)
  at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatch(PatchDownloaderImpl.java:136)
  ... 23 more
Failed to build patch for build #1 {build id=3614, buildTypeId=BlogApi_Build}, VCS root: "https://gitlab/my-repo/my-repo.git#refs/heads/main" {instance id=35, parent internal id=145, parent id=BlogApi_HttpsGitlabComBlog125apisBlogApiGitRefsHeadsMain, description: "https://gitlab/my-repo/my-repo.git#refs/heads/main"}, due to error: 'git fetch' command failed (repository dir: <TeamCity data dir>/system/caches/git/git-6C486741.git).
exception: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/lib/jvm/java-21-openjdk-amd64/bin/java" (in directory "/root/.BuildServer/system/caches/git/git-6C486741.git"): error=0, Failed to exec spawn helper: pid: 895428, exit value: 1
exit code: -1
Publishing artifacts
  Collecting files to publish: [/home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/agentTmp/build_stages.txt=>.teamcity/perfmon/]
Publishing 1 file using [WebPublisher]: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/agentTmp/build_stages.txt => .teamcity/perfmon
Publishing 1 file using [ArtifactsCachePublisherImpl]: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/agentTmp/build_stages.txt => .teamcity/perfmon
Publishing artifacts
  Collecting files to publish: [/home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/buildTmp/.teamcity/docker/build_1/events.json => .teamcity/docker/]
Publishing internal artifacts
Publishing 1 file using [WebPublisher]
Publishing 1 file using [WebPublisher]: /home/my-pc/Desktop/DevOps/TeamCity/buildAgent/temp/buildTmp/.teamcity/docker/build_1/events.json => .teamcity/docker

I have tried removing /root/.BuildServer/system/caches, but it does not work.

I suspect the agent does not have permission to run git fetch in the teamcity data.

TeamCity info:

  • Version: 2024.12.2 (build 174504)
  • OS: Ubuntu 24.04
  • Git is available in /usr/bin.

Any solutions please ?

Thanks,

Share Improve this question edited Feb 17 at 2:27 Redplane asked Feb 16 at 19:17 RedplaneRedplane 3,1514 gold badges35 silver badges60 bronze badges 1
  • Are you using server-side checkout or agent-side checkout? Also, please share the teamcity-vcs.log – slattman Commented Feb 16 at 21:15
Add a comment  | 

1 Answer 1

Reset to default 0

Try fetching all heads but you'll need to enable it first firstteamcity.git.fetchAllHeads=true

It may also be worth checking if the remote repo is fine by using another client like tortoisegit?

发布评论

评论列表(0)

  1. 暂无评论