Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-12353

Git command fails on Windows when git installed in default place (C:\Program Files\Git).

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • git-plugin

      I am running Jenkins on a Linux machine with a Windows slave. On the Windows machine have git installed in its default place (C:\Program Files\Git). I included the git bin directory (C:\Program Files\Git\bin) in the Windows machine's path, hence putting git.exe on the path, and the slave still failed to find the git command.

      When I moved the git install to C:\Git, and updated my path, it started to work.

          [JENKINS-12353] Git command fails on Windows when git installed in default place (C:\Program Files\Git).

          James Nord added a comment - - edited

          I can confirm this on Win2008 R2 SP1.
          Git is installed in "C:\Program Files (x86)\Git\cmd"

          The path is verified as correct by runing a freestyle build

          Started by user xxx
          Building remotely on xxx-w2k8-x64-01
          [wingittest] $ cmd /c call C:\Users\jenkins\AppData\Local\Temp\hudson1046997614926702075.bat
          
          C:\jenkins\workspace\wingittest>git --version 
          git version 1.7.8.msysgit.0
          Finished: SUCCESS
          

          and a failed job on the same slave where hudson is checking out from git

          Started by user xxxxx
          Building remotely on xxxxx-w2k8-x64-01
          
          Deleting project workspace... Checkout:commit / C:\jenkins\workspace\CAB_Infrastructure/Build/settings/commit - hudson.remoting.Channel@176bc096:xxxx-w2k8-x64-01
          Using strategy: Default
          Checkout:commit / C:\jenkins\workspace\CAB_Infrastructure\Build\settings\commit - hudson.remoting.LocalChannel@13f7780d
          Wiping out workspace first.
          Cloning the remote Git repository
          Cloning repository origin
          Error trying to determine the git version: Error performing command: git --version
          Cannot run program "git" (in directory "C:\jenkins\workspace\testjob\commit"): CreateProcess error=2, The system cannot find the file specified
          Assuming 1.6
          ERROR: Error cloning remote repo 'origin' : Could not clone ssh://xxxxxxxx@xxx.yyy.zzz.com:29418/test/citest.git
          ERROR: Cause: Error performing command: git clone -o origin ssh://xxxxxxxx@xxx.yyy.zzz.com:29418/test/citest.git C:\jenkins\workspace\testjob\commit
          Cannot run program "git": 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:1046)
          	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:972)
          	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:1994)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          	at hudson.remoting.Request$2.run(Request.java:287)
          	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.runWorker(Unknown Source)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          	at java.lang.Thread.run(Unknown Source)
          

          James Nord added a comment - - edited I can confirm this on Win2008 R2 SP1. Git is installed in "C:\Program Files (x86)\Git\cmd" The path is verified as correct by runing a freestyle build Started by user xxx Building remotely on xxx-w2k8-x64-01 [wingittest] $ cmd /c call C:\Users\jenkins\AppData\Local\Temp\hudson1046997614926702075.bat C:\jenkins\workspace\wingittest>git --version git version 1.7.8.msysgit.0 Finished: SUCCESS and a failed job on the same slave where hudson is checking out from git Started by user xxxxx Building remotely on xxxxx-w2k8-x64-01 Deleting project workspace... Checkout:commit / C:\jenkins\workspace\CAB_Infrastructure/Build/settings/commit - hudson.remoting.Channel@176bc096:xxxx-w2k8-x64-01 Using strategy: Default Checkout:commit / C:\jenkins\workspace\CAB_Infrastructure\Build\settings\commit - hudson.remoting.LocalChannel@13f7780d Wiping out workspace first. Cloning the remote Git repository Cloning repository origin Error trying to determine the git version: Error performing command: git --version Cannot run program "git" (in directory "C:\jenkins\workspace\testjob\commit"): CreateProcess error=2, The system cannot find the file specified Assuming 1.6 ERROR: Error cloning remote repo 'origin' : Could not clone ssh://xxxxxxxx@xxx.yyy.zzz.com:29418/test/citest.git ERROR: Cause: Error performing command: git clone -o origin ssh://xxxxxxxx@xxx.yyy.zzz.com:29418/test/citest.git C:\jenkins\workspace\testjob\commit Cannot run program "git": 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:1046) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:972) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:1994) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:287) 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.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

          James Nord added a comment -

          I also failed to get the workaround working.

          changed the path to c:\progra~2\git\cmd (stopped service) and restarted via jenkins
          Copied c:\program files\x86\git\ to c:\git, updated path (stopped service) and restarted via jenkins

          Both times I checked the nod configuration had the correct path in computer/xxxxx-w2k8-x64-01/systemInfo

          Both Jenkins failed to use git.

          James Nord added a comment - I also failed to get the workaround working. changed the path to c:\progra~2\git\cmd (stopped service) and restarted via jenkins Copied c:\program files\x86\git\ to c:\git, updated path (stopped service) and restarted via jenkins Both times I checked the nod configuration had the correct path in computer/xxxxx-w2k8-x64-01/systemInfo Both Jenkins failed to use git.

          James Nord added a comment -

          The workaround that worked for me was to configure the git tool location in for the windows node. (http://jenkins/computer/slavename/configure)

          Annoying that git is picked form the path on Unix but not windows.

          James Nord added a comment - The workaround that worked for me was to configure the git tool location in for the windows node. ( http://jenkins/computer/slavename/configure ) Annoying that git is picked form the path on Unix but not windows.

          Mark Waite added a comment -

          I can't duplicate this bug report. Most of the Windows machines I configure have Git in the PATH, just as described in this bug report, and they work quite well. I don't configure the location of Git in the Jenkins administration, and I don't make any changes to other Git related configuration and it works great for me.

          Can you offer other insights about what might be different in your environment compared to mine?

          I add the Git\bin directory to the PATH, not the Git\cmd directory, since I've seen bug reports that it is not sufficient to add the Git\cmd directory to the PATH.

          Mark Waite added a comment - I can't duplicate this bug report. Most of the Windows machines I configure have Git in the PATH, just as described in this bug report, and they work quite well. I don't configure the location of Git in the Jenkins administration, and I don't make any changes to other Git related configuration and it works great for me. Can you offer other insights about what might be different in your environment compared to mine? I add the Git\bin directory to the PATH, not the Git\cmd directory, since I've seen bug reports that it is not sufficient to add the Git\cmd directory to the PATH.

          Mark Waite added a comment -

          Closing this report after several weeks with no response from the submitter.

          Mark Waite added a comment - Closing this report after several weeks with no response from the submitter.

          Laino Santos added a comment -

          This happens because default installation configures Path variable to {git_dir}/cmd, where there is no git.exe. Change de Path to {git_dir}/bin. https://itsecureadmin.com/2011/05/jenkins-slave-on-windows-git-clone-failure/

          Laino Santos added a comment - This happens because default installation configures Path variable to {git_dir}/cmd, where there is no git.exe. Change de Path to {git_dir}/bin. https://itsecureadmin.com/2011/05/jenkins-slave-on-windows-git-clone-failure/

            abayer Andrew Bayer
            aberent Anthony Berent
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: