TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Git (JetBrains)

Last modified: 20 April 2023

This page contains description of the fields and options available when setting up VCS roots using the Git Version Control System. The VCS is visible as "Git (JetBrains)" in VCS chooser to eliminate confusion with third-party plugin if third-party plugin is installed and as "Git" otherwise.

General Settings



The following protocols are supported for the server-side VCS Checkout Mode:

  • ssh: (e.g. ssh://git.somwhere.org/repos/test.git, ssh://git@git.somwhereElse.org/repos/test.git, scp-like syntax: git@git.somwhere.org:repos/test.git)

    note

    Scp-like syntax requires a colon after hostname, while usual ssh url does not. This is a common source of errors.

  • git: (e.g. git://git.kernel.org/pub/scm/git/git.git)

  • http: (e.g. http://git.somewhere.org/projects/test.git)

  • file: (e.g. file:///c:/projects/myproject/.git)

    note

    When you run TeamCity as a Windows service it cannot access a mapped network drives and repositories located on them.

Authentication Settings



Server Settings



Agent Settings



Please note that agent-side checkout has limited support for SSH. The only supported authentication method is "Default Private Key". Also you should set "StrictHostKeyChecking" to "no" in <USER_HOME>\.ssh\config, or add keys of remote hosts to the Known-Hosts database manually. If you plan to use VCS Checkout Mode, you need to have Git 1.6.4+ installed on the agents.

Git executable on the agent



Path to git executable can be configured in the agent properties by setting the value of an environment variable TEAMCITY_GIT_PATH.

If path to git is not configured, git-plugin tries to detect installed git on the start of the agent. It first tries to run git at following locations:

  • for windows - try to run git.exe, at:

    • C:\Program Files\Git\bin

    • C:\Program Files (x86)\Git\bin

    • C:\cygwin\bin

  • for *nix - try to run git, at:

    • /usr/local/bin

    • /usr/bin

    • /opt/local/bin

    • /opt/bin

If git wasn't found at any of these locations, try to run git accessible from the $PATH.

If compatible git (1.6.4+) is found - it is reported in the TEAMCITY_GIT_PATH environment variable. This variable can be used in Path to git field in VCS root settings. As a result, configuration with such a VCS root will run only on agents where git was detected or specified in agent properties.

Internal Properties



For Git VCS it is possible to configure the following Configuring TeamCity Server Startup Properties:

Build Agent Configuration for Git:

Limitations



  • When using checkout on agent, limited subset of checkout rules is supported, because Git cannot clone a subdirectory of repository. You can only map whole repository to a specific directory using following checkout rule +:.=>subdir. The rest checkout rules are not supported.

Known Issues



  • Tagging is not supported over HTTP protocol

  • java.lang.OutOfMemoryError while fetch repository. Usually happens when there are big files in repository. By default TeamCity runs fetch in a separate process, to run fetch in the server process set Configuring TeamCity Server Startup Properties teamcity.git.fetch.separate.process to false.

  • Teamcity ran as a Windows service cannot access a network mapped drives, so you cannot work with git repositories located on such drives. To make this work run TeamCity using teamcity-server.bat.

  • checkout on agent using ssh protocol can be slow due to java SSH implementation (see TW-14598 for details). To use native SSH implementation set teamcity.git.use.native.ssh to true.

  • inflation using streams in JGit prevents OutOfMemoryError but can be time consuming (see related thread at jgit-dev for details and TW-14947 issue related to the problem). If you meet conditions similar to described in the issue - try to increase teamcity.git.stream.file.threshold.mb. Additionally it is recommended to increase overall amount of memory dedicated for TeamCity to prevent OutOfMemoryError.

Development Links



Git support is implemented as an open-source plugin. For development links refer to the Git.