I had issues with getting Git up and running in a Hudson that was hosted as a Windows Service. The Git Commands would simply hang, the console output stopped at the line where the Git command was executed.

If I took the service down and started hudson from the command-line everything worked out great.

It turns out that when Hudson is started as a windows service there is no HOME environment variable set. And this is where Git finds the keys for SSH identification.

I found information regarding this here:

http://stackoverflow.com/questions/3188710/hudson-git-plugin-not-working-on-windows

http://stackoverflow.com/questions/3182012/problem-with-hudson-git-gitosis-on-windows

The fix for me was to make a simple change to the hudson.xml that is located in HUDSON_HOME.

<id>hudson</id>  
<name>Hudson</name>  
<description>This service runs Hudson continuous integration system.></description>  
<env name="HUDSON_HOME" value="%BASE%"/>  
<env name="HOME" value="C:\Documents and Settings\hudson"/>  

This adds the environment variable for the home directory when the service starts up. Now Git can fetch when I run Hudson as a service. Naturally you have to change the path to correspond to the location of the .shh/ directory to use. In our case there is a dedicated user running hudson.