Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set git commit --author properly from rake running under LocalSystem account?

I have Rake build script for my CI process running under TeamCity@windows. One of the steps that the script does is to commit some changes to remote repository (this repository represents real production environment on my shared hosting. It has only ftp access, so I map this location as a windows drive)

Part of ruby looks like this:

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

However, when script is run by teamcity build agent (which runs under LocalSystem account), I get the following warning:

[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 [email protected]
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <[email protected]>'
9 files changed, 0 insertions(+), 0 deletions(-)

Reading what's written I altered my rake script command to:

  sh "git commit --author='TeamCity <[email protected]>' -v -m #{version_tag}"

but this command results with a weird failure (previously commit was successful, but with warning). This is the only thing I get as an output from TeamCity build log:

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

How can I successfully set up an author for a commit for script running under LocalSystem account ?

like image 368
Łukasz Podolak Avatar asked Mar 05 '11 11:03

Łukasz Podolak


People also ask

How do I change the author name in Visual Studio?

Change your display info through Team Explorer > Settings > Repository Settings . EDIT: Just noticed you're talking about existing commits, take a look at Change commit author at one specific commit. Addition: If you want to set user.name for a repo you probably want to set user. email as well.


1 Answers

I found a different solution to my problem. I configured TeamCity agent to run under custom windows account. I needed to log in to this account, and set both:

git config --global user.email [email protected]
git config --global user.name TeamCity

With this set up, the command:

sh "git commit --author='TeamCity <[email protected]>' -v -m #{version_tag}"

still generates the weird: "The system cannot find the file specified." error. However, having account settings set up globally I could remove the --author option from the commit statement, leaving it with:

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

and that produces the desired effect.

like image 105
Łukasz Podolak Avatar answered Nov 05 '22 05:11

Łukasz Podolak