How to debug Cannot run program “C:\Program Files\Git” in a Jenkins job?

I’m using jenkins to build my git project, this is the error I am getting when see the log.
I am using git plugin in jenkins.

How would you troubleshoot that error message?

  • How do I adapt my svn:externals strategy to git submodules?
  • Reuse GIT_WORK_TREE in post-receive hook to rm a few files
  • GitHub issues - Reference a file in the repo
  • Is there a way to get the git root directory in one command?
  • Are their names the same: a local-tracking branch, the corresponding remote-tracking branch, and the corresponding remote branch being tracked?
  • Git Checkout Latest Tag
  • Started by user anonymous
    Building in workspace E:\sw\jenkins\workspace\se12
    ERROR: Workspace has a .git repository, but it appears to be corrupt.
    hudson.plugins.git.GitException: Error performing command: git rev-parse --is-inside-work-tree
    
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1180)
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1150)
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1146)
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:962)
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:972)
    hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:651)
            at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
        Caused by: java.io.IOException: Cannot run program "C:\Program Files\Git" (in directory "E:\sw\jenkins\workspace\se12"): CreateProcess error=5, Access is denied
            at java.lang.ProcessBuilder.start(Unknown Source)
            at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1169)
            ... 16 more
        Caused by: java.io.IOException: CreateProcess error=5, Access is denied
            at java.lang.ProcessImpl.create(Native Method)
            at java.lang.ProcessImpl.<init>(Unknown Source)
            at java.lang.ProcessImpl.start(Unknown Source)
            ... 22 more
        Cloning the remote Git repository
        Cloning repository $ git clone \\SE12\Adempiere370new\.git
        Fetching upstream changes from $ git clone \\SE12\Adempiere370new\.git
        ERROR: Error cloning remote repo 'origin'
        hudson.plugins.git.GitException: Error performing command: git fetch --tags --progress $ git clone \\SE12\Adempiere370new\.git +refs/heads/*:refs/remotes/origin/*
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1180)
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1043)
    hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:651)
            at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    
        Caused by: java.io.IOException: Cannot run program "C:\Program Files\Git" (in directory "E:\sw\jenkins\workspace\se12"): CreateProcess error=5, Access is denied
    org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1169)
            ... 14 more
    

  • “git push” failed: “You did not specify any refspecs to push”
  • gitignore directory pattern ignores folder with same suffix, but I want to include it
  • Github clone with oauth access token
  • How can I move a single directory from a git repository to a new repository whilst maintaining the history?
  • git push --recurse-submodules=on-demand is not truly recursive
  • Jenkins Can't Run xcodebuild from project folder
  • 2 Solutions collect form web for “How to debug Cannot run program “C:\Program Files\Git” in a Jenkins job?”

    Maybe you incorrectly set the git executable path.

    It shouldn’t be C:\Program Files\Git, but C:\Program Files\Git\bin\git.exe
    (this is similar to JENKINS-6181)

    The Git plugin page does mention:

    If you are seeing output indicating Git could not clone, something like the output below, go to to the Jenkins configuration settings (not the project settings, the global ones) and change the Git path to a fully qualified path (eg. not “git” but “/usr/bin/git” or wherever your Git binary is installed).

    In your case, check that C:\Program Files\Git is indeed your Git installation path.

    If you know the git path correctly then only mention the path of git.exe else mention “git” in the URL .When it executes it checks on the jenkin sever PATH enviornment variable and find the git itself in one of the path.

    Git Baby is a git and github fan, let's start git clone.