首页 文章

在TeamCity构建步骤中使用git命令

提问于
浏览
39

我的一个TeamCity v7.0构建项目依赖于在当前开发分支和主分支之间使用diff来确定需要运行的内容 . 我写了一个小脚本,使用类似的东西:

git diff origin/master..origin/QA --name-only --diff-filter=AM | DoSomethingWithThoseFiles

不幸的是,构建日志表明 git diff 无效 . 当我进入这个项目的buildAgent / work目录时,我看到没有 .git 文件夹,所以它无法执行所需的git操作 .

我把 teamcity.git.use.local.mirrors=true 放在了 buildAgent.properties 文件中提到的 buildAgent.properties 文件中,但这似乎没有任何帮助 .

我可以做些什么来在脚本中为我的构建步骤更改两个分支之间的文件列表?

2 回答

  • 49

    尝试将VCS签出模式更改为"Always checkout files on agent",如here所述 . 这应该使构建脚本能够访问.git文件夹 .

  • 7

    @Mike Two的答案是正确的,需要配置VCS root以在服务器上的Agent-not-上自动使用Checkout模式 . TC文档没有提到默认情况下将此必需设置隐藏为“高级” . 所以这是一张需要寻找什么的图片 .

    Advanced Settings

    仅供参考,我的具体VS2013解决方案步骤错误来自MSBuild,如下所示 . 我使用的是最新的TeamCity Enterprise 9.0 EAP(版本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]

    //编辑;我不知道如何将其添加到评论中 .

相关问题