Using git commands in a TeamCity Build Step

寵の児 提交于 2019-11-28 22:23:25
Mike Two

Try changing the VCS checkout mode to "Always checkout files on agent" as documented here. That should give the build script access to the .git folder.

@Mike Two's answer is correct, one needs to configure the VCS root to use Checkout mode Automatically on Agent -not- on the server. The TC docs do not mention that this required setting is hidden by default as 'advanced'. So here is a picture of what to look for.

FYI, My specific VS2013 Solution step error was from MSBuild, as below. I am using the latest TeamCity Enterprise 9.0 EAP (build 31963). [PreBuildEvent] Exec [14:21:55][Exec] git rev-parse --short=9 HEAD > "C:\TeamCity\buildAgent\work\e5e910561e800525\MYPROJECT\bin\Debug\version.txt" [14:21:55][Exec] fatal: Not a git repository (or any of the parent directories): .git [14:21:55][Exec] C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1131, 5): error MSB3073: The command "git rev-parse --short=9 HEAD > "C:\TeamCity\buildAgent\work\e5e910561e800525\Higgens\bin\Debug\version.txt"" exited with code 128. [14:21:55]

//edit; I didn't know how to add this to a comment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!