Łuk*_*lak 8 git rake author commit
我在TeamCity @ windows下运行的CI过程中有Rake构建脚本.该脚本执行的一个步骤是将一些更改提交到远程存储库(此存储库代表我的共享主机上的真实生产环境.它只有ftp访问权限,因此我将此位置映射为Windows驱动器)
红宝石的一部分看起来像这样:
sh "git commit -v -m #{version_tag}"
Run Code Online (Sandbox Code Playgroud)
但是,当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(-)
Run Code Online (Sandbox Code Playgroud)
阅读所写的内容我将我的rake脚本命令改为:
sh "git commit --author='TeamCity <no@email.com>' -v -m #{version_tag}"
Run Code Online (Sandbox Code Playgroud)
但是这个命令导致了一个奇怪的失败(先前提交成功,但有警告).这是我从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.
Run Code Online (Sandbox Code Playgroud)
如何为在LocalSystem帐户下运行的脚本的提交成功设置作者?
Łuk*_*lak 16
我找到了解决问题的不同方法.我将TeamCity代理配置为在自定义Windows帐户下运行.我需要登录此帐户,并设置两个:
git config --global user.email some@email.com
git config --global user.name TeamCity
Run Code Online (Sandbox Code Playgroud)
通过此设置,命令:
sh "git commit --author='TeamCity <some@email.com>' -v -m #{version_tag}"
Run Code Online (Sandbox Code Playgroud)
仍然会产生奇怪的:"系统无法找到指定的文件." 错误.但是,在全局设置帐户设置后,我可以从commit语句中删除--author选项,并将其保留为:
sh "git commit -v -m #{version_tag}"
Run Code Online (Sandbox Code Playgroud)
并产生预期的效果.