Teamcity build failes when VCS Checkout mode is set to Agent

Answered

Hi,

I have TeamCity installed on one machine as a server and on another machine as a build agent (both are windows 7). There is a single project defined, and its VCS Root is configured to authenticate users via SSH keys, and it's using the authentication method 'Default Private Key'.

When trying to run a build configuration with VCS Checkout Mode set to server, everything works fine.
However, when the VCS Checkout Mode is set to agent, the build fails.

It say's :

  • Failed to perform checkout on agent: '"C:\Program Files\Git\bin\git.exe" fetch --progress origin +refs/heads/master:refs/heads/master' command failed.
    exit code: 128
    stderr: There was a problem while connecting to gitlab:22
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

The relevant part of the build log :

  • [11:29:52]Updating sources: agent side checkout (3s)
    [11:29:52][Updating sources] Using vcs information from agent file: b3a2bb30f16c7f72.xml
    [11:29:54][Updating sources] VCS Root: git (1s)
    [11:29:54][VCS Root: git] revision: b3059cc954251ba531eadada34ee7ee9e35c0217
    [11:29:54][VCS Root: git] Git version: 2.10.0.0
    [11:29:54][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" show-ref
    [11:29:54][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" show-ref refs/remotes/origin/master
    [11:29:54][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" show-ref refs/heads/master
    [11:29:55][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" fetch --progress origin +refs/heads/master:refs/heads/master
     >> [11:29:55][[C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" fetch --progress origin   +refs/heads/master:refs/heads/master] There was a problem while connecting to gitlab:22
    [11:29:55][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" init --bare
    [11:29:55][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" remote add origin git@gitlab:client/test-repo.git
    [11:29:55][VCS Root: git] [C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" fetch --progress origin +refs/heads/master:refs/heads/master
     >> [11:29:56][[C:\dev\teamcity\BuildAgent\system\git\git-A8F0811E.git]: "C:\Program Files\Git\bin\git.exe" fetch --progress origin +refs/heads/master:refs/heads/master] There was a problem while connecting to gitlab:22
    [11:29:56][Updating sources] Failed to perform checkout on agent: '"C:\Program Files\Git\bin\git.exe" fetch --progress origin +refs/heads/master:refs/heads/master' command failed. exit code: 128 stderr: There was a problem while connecting to gitlab:22 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

The keys are stored on '%HOME%\.ssh\id_rsa' (on both machines, where %HOME%==C:\users\the_correct_user).
Of course, the keys that are used have the required privileges.

Any ideas?

Thanks,

Tal!

7 comments

Solved.

After adding "teamcity.git.use.native.ssh=true" to the "buildAgent.properties" file the build configuration worked.

3

After upgrading from 9.0.1 to 10.0.2 this problem started happening for some of our repositories that are all simple file shares accessed anonymous in the VCS root. Odd that some continued to work, odder that some broke, odd that after adding "teamcity.git.use.native.ssh=true" to the "buildAgent.properties" file all connections appear to be working fine.

Thanks Tal for coming back to post your fix after you worked it out. Saved me immense trouble doing the same!

0

Have used "teamcity.git.use.native.ssh=true" to "buildAgent.properties" .it seems this does not work out.Below is the build log for the error.

Updating sources] Failed to perform checkout on agent: '"C:\Program Files (x86)\Git\bin\git.exe" fetch --progress origin +refs/heads/feature/REM-20425-portal-api-arm:refs/heads/feature/REM-20425-portal-api-arm' command failed.
exit code: 128
stderr: There was a problem while connecting to gitpub.rakuten-it.com:7999
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

2

Thanks Tal for posting this solution! We were banging our heads against the wall trying to figure out why the Git TLS change today could have broken our agents ability to build through teamcity when it worked on each agent when run locally! It was super strange but adding that setting seems to have made the problem go away. Awesome!!

2

All our builds suddenly stopped working today. Adding "teamcity.git.use.native.ssh=true" helped to resolve this issue. Thanks!

0

For those encountering the issue with github in the past 24 hours (since 22/2/2018), check out the solution for 2017.2 and workarounds for earlier versions here: https://youtrack.jetbrains.com/issue/TW-52052#comment=27-2607007 (thanks @spav5)

0

Git removed support for:

- TLSv1/TLSv1.1

- diffie-hellman-group1-sha1

- diffie-hellman-group14-sha1

0

Please sign in to leave a comment.