8

我有在 TeamCity@windows 下运行的 CI 进程的 Rake 构建脚本。脚本执行的步骤之一是向远程存储库提交一些更改(此存储库代表我共享主机上的真实生产环境。它只有 ftp 访问权限,因此我将此位置映射为 Windows 驱动器)

红宝石的一部分看起来像这样:

  sh "git commit -v -m #{version_tag}"

但是,当脚本由 teamcity 构建代理(在 LocalSystem 帐户下运行)运行时,我收到以下警告:

[master e7a5a8d] v0.4.7.0
Committer: unknown <SYSTEM@.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
9 files changed, 0 insertions(+), 0 deletions(-)

阅读所写的内容,我将 rake 脚本命令更改为:

  sh "git commit --author='TeamCity <no@email.com>' -v -m #{version_tag}"

但是这个命令会导致一个奇怪的失败(之前提交是成功的,但是有警告)。这是我从 TeamCity 构建日志中得到的唯一输出:

git commit --author='TeamCity <no@email.com>' -v -m v1.0.18.10
[19:06:20]: [Execute _3_deployment_stage:to_ftp] The system cannot find the file specified.

如何为在 LocalSystem 帐户下运行的脚本成功设置作者?

4

1 回答 1

16

我找到了一个不同的解决方案来解决我的问题。我将 TeamCity 代理配置为在自定义 Windows 帐户下运行。我需要登录到这个帐户,并设置两者:

git config --global user.email some@email.com
git config --global user.name TeamCity

有了这个设置,命令:

sh "git commit --author='TeamCity <some@email.com>' -v -m #{version_tag}"

仍然产生奇怪的:“系统找不到指定的文件。” 错误。但是,在全局设置帐户设置后,我可以从提交语句中删除 --author 选项,将其保留为:

sh "git commit -v -m #{version_tag}"

并产生预期的效果。

于 2011-03-06T11:45:09.970 回答