Why does this jenkins job never complete?

1.7k views Asked by At

I have a windows 8 jenkins slave (really more than one) and I want to have a task which clones a mirror of a git repository if it doesn't exist and always fetches latest.

I've got this 'execute windows batch' step:

if not exist "server-reference" (
  git clone --mirror [email protected]:something/somewhere.git server-reference
)
pushd server-reference
git fetch --all
popd
exit /B %ERRORLEVEL%

The console output for the job gets to this point

c:\jenkins\workspace\thing\server-reference>git fetch --all
Fetching origin

and never finishes

If I switch an exit above the fetch then I get the expected exit.

And if I run the batch file commands as the jenkins user on the windows box everything works as expected. So I (think I) know that the git fetch --all runs on the slave without prompting for input

How do I amend this script so that it completes when Jenkins runs it?

1

There are 1 answers

2
twasbrillig On BEST ANSWER

A number of things can cause this problem. Here are things that have worked for me in the past.

  1. I know you stated this above, but just to double-check: Confirm that when you run git fetch --all manually on the slave machine, it doesn't prompt you for a password. If it does, Jenkins would get stuck on that step, so you'll need to set up an SSH keypair.

  2. Make sure that you are calling C:\Program Files (x86)\Git\cmd\git.exe and not C:\Program Files (x86)\Git\bin\git.exe in Jenkins. The second one can cause this problem in certain versions of git.

  3. On the slave machine, set the environment variable HOME to C:\users\[username], filling in your user's username. (For older OS's it was C:\Documents and Settings\[username].) Then recycle the Jenkins service and try again.

  4. Double check that in Administrative Tools > Services, the Jenkins slave service "Log On As" is set to your user and the password is correct. If not, set those values, recycle the Jenkins service and try again.

  5. If none of the above worked, try uninstalling and reinstalling git. And if you aren't using it, try installing the newest version of git.