4

We have been working for years with TeamCity and for several weeks with git as version control system. I have set up integration with TeamCity and that has been working fine. We have four different projects that use git

Recently some of the projects have stopped working intermittently.

The build fails to start. Messages like this is shown in red. (with varying agents):

Failed to start build #1094 on Teamcityagent8_Continuous5 (and 1 more)

The build log says very little:

[16:12:46]Checking for changes
[16:12:49]Failed to start build
[16:12:49]Failed to collect changes, error: Error collecting changes for VCS repository 'http://foo-app-sprint:7990/scm/BAR/qux.git#master'
'git fetch' command failed.
stderr: Socket Closed
[16:12:49]Cannot calculate build metric 'percent of class coverage' - no value

Strangely there are other projects that have very similar configuration that work just fine. They use the same build agents.

We use Atlassian Stash as Git server. I have looked at all the logs there, and nothing at all happens when I force a run in team city. So, it would seem that TeamCity does not even reach the Git server.

If I test the VCS connection in TeamCity it works.

I have tested restarting Stash. It did not help.

We are working with feature branches. But I have tested turning those off and it did not help.

Today the builds have actually worked a couple of times, but the problem returns.

We are using TeamCity Enterprise 7.1.4 (build 24331) and Atlassian Stash v2.1.2. Both the build agents and Stash run on windows servers.

Any idea on what is wrong and how to solve it?

I have posted this question on the jetbrains developer forum, but gotten no answers.

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
Klas Mellbourn
  • 347
  • 1
  • 5
  • 10
  • have you tried running the offending 'git fetch' command manually? – sendmoreinfo Apr 28 '13 at 12:36
  • @sendmoreinfo Yes. As we are using git as our version control system, I run git fetch many times daily on my development machine. It has never resulted in a "Socket Closed" error. – Klas Mellbourn Apr 28 '13 at 13:08
  • On the build agent, and in the same environment as build agent executes it? – sendmoreinfo Apr 28 '13 at 17:00
  • In our corporate environment, I do not have direct access to the Team City agents. However, two of the projects work fine all the time, even when there is a problem with one of the projects. So they must execute `git fetch` without error. – Klas Mellbourn Apr 28 '13 at 17:01
  • Just had this happen for the first time after using Teamcity for ~4 years (with ~30 repositories, and dozens to hundreds of builds per day). Deleted cache folder and worked fine again after that. – gregmac Dec 19 '16 at 21:22

2 Answers2

4

I had a similar issue with TeamCity.

Error: 'git fetch' command failed . . . Caused by Missing commit.

Fetching on my development machine worked fine. Also, the missing commit was present using command line.

$ git show b18264d

I fixed this error by:

  1. Cloning a bare repo from my local git repo

$ git clone --bare MyGitRepo MyGitRepo.git

  1. Replacing the git repo on the server with the bare clone from #1
  2. Stopping TeamCity Service
  3. Deleting C:\ProgramData\JetBrains\TeamCity\system\caches\git
  4. Restarting TeamCity Service
3

The last part of @Fuyu Persimmon's answer is what fixed it for me.

You just need to delete the git cache on the build server (default path .BuildServer/system/caches/git [source]) and kick off the build again.

Stelloy
  • 141
  • 6