Jenkins Slave on Windows – git clone failure

I recently setup a Jenkins job to run on a Windows slave that was triggered from a successful build on a Linux master and it failed with the following error:

Started by user anonymous
Building remotely on 10.13.0.11
Checkout:Deploy App Code / c:\jenkins-slave\workspace\Deploy App Code - hudson.remoting.Channel@1e5cd7a:10.13.0.11
Using strategy: Default
Checkout:Deploy App Code / c:\jenkins-slave\workspace\Deploy App Code - hudson.remoting.LocalChannel@132c800
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Error performing command: git --version
Cannot run program "git" (in directory "c:\jenkins-slave\workspace\Deploy App Code"): CreateProcess error=2, The system cannot find the file specified
ERROR: Cause: Cannot run program "git" (in directory "c:\jenkins-slave\workspace\Deploy App Code"): CreateProcess error=2, The system cannot find the file specified
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:977)
	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:908)
	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:1979)
	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
	at hudson.remoting.Request$2.run(Request.java:270)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1$1.run(Engine.java:60)
	at java.lang.Thread.run(Unknown Source)

The problem is that msysgit is installed with a path that points to the git.cmd executable batch file rather than git.exe in bin of the msysgit package.

To resolve this, I updated the PATH environment variable to point to the bin directory where git.exe was at rather than the git.cmd script.

I’ve seen a lot of folks change the Jenkins config to point to git.cmd instead of git but this will not work in an environment where you have both Linux and Windows hosts.


Comments

2 responses to “Jenkins Slave on Windows – git clone failure”

  1. hi, i tried setting PATH to both of these – C:\Program Files\Git\bin && C:\Program Files\Git\mingw64\bin, but still its afiling with same issue –
    Caused by: java.io.IOException: Cannot run program “git” (in directory “C:\”): CreateProcess error=2, The system cannot find the file specified

  2. Hi Massi,

    Can you confirm that the git.exe file exists in one of those locations?

Leave a Reply

Your email address will not be published. Required fields are marked *