GIT Configuration with Hudson on Ubuntu’s Tomcat

During my recent migration from using SVN to using GIT for my open source projects I was reconfiguring my Hudson CI server and started seeing this message:


Caused by: hudson.plugins.git.GitException: Command returned status code 128:
*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

I was a little confused to see this message since I had already configured git to have my user name and email. Then I remembered that hudson is running on tomcat which is running with the tomcat6 user. I needed to configure the tomcat6 user to have the git configuration necessary to tag on the git repositories.

[UPDATE: 24 Jun 2010]

I was working on repeating this process on Ubuntu 10.04 and was getting permission errors running the command to set the git config for the tomcat6 user. Here is an updated method:

First we need to create a .gitconfig file for the tomcat6 user:


sudo touch /usr/share/tomcat6/.gitconfig
sudo chown tomcat6:tomcat6 /usr/share/tomcat6/.gitconfig
sudo nano /usr/share/tomcat6/.gitconfig

Place the following in the .gitconfig file:


[user]
name = Hudson
email = hudson@myDomain.com

Once the file is saved–you may need to restart Tomcat–it should pick up your git configuration.

[/UPDATE]

[ORIGINAL: see updated instructions above]

Setup the git configuration for the tomcat6 user by doing the following:


sudo -s -H -u tomcat6
git config --global user.name "Hudson"
git config --global user.email "hudson@mydomain.com"
exit

As a note, if you are using hudson to commit and push to another repository these configuration settings will be used for all commits done by Hudson.

The next step is to let hudson know where the HOME is for the tomcat6 user. On the hudson/configure page there is a checkbox for defining environment variables. Once it is checked you will be able to put in a key-value pair. Add the following pair and save your configuration:


name: HOME
value: /usr/share/tomcat6/

The next time a hudson project is built you should see the following line close to the top of the console output:

Env: HOME=/usr/share/tomcat6/

[/ORIGINAL]

The git plugin should now be able to successfully tag the repository and continue with the build.

Add Your Comments

Disclaimer
Your email is never published nor shared.
Required
Required
Tips

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <ol> <ul> <li> <strong>

Ready?