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

Git CLI cannot clone on Windows using GIT_SSH to set credentials when running as a service

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-client-plugin
    • None
    • Git plugin 2.0, git client plugin 1.4.6, Windows 8, Windows Server 2011, Windows 7

      A git job configured to use the command line implementation with Git plugin 2.0 and git client plugin 1.4.6 fails to clone on Windows, but successfully clones on Linux.

      The problem seems to be that it is trying to configure an environment (setting SSH_PASS=echo) for the launched command, even though Windows does not use the same technique to pass environment variables to a process.

      I think there was a different behavior in prior versions of git-client.

      I created the job by:

      1. Configure a global ssh credential
      2. Create a new job, restrict it to only run on Windows
      3. Use a git ssh protocol URL (like ssh://wheezy64b/var/cache/git/mwaite/bin.git)
      4. Select the correct ssh credential from the dropdown list
      5. Add a build step (I used XShell "echo hello world")
      6. Save the job
      7. Run the job

      Stack trace on Windows:

      Started by user anonymous
      Building remotely on alan-pc in workspace C:\J\workspace\git-cli-ssh
      Cloning the remote Git repository
      Cloning repository ssh://wheezy64b/var/cache/git/mwaite/bin.git
      git --version
      git version 1.8.3.msysgit.0
      using GIT_SSH to set credentials Jenkins
      ERROR: Error cloning remote repo 'origin'
      hudson.plugins.git.GitException: Could not clone ssh://wheezy64b/var/cache/git/mwaite/bin.git
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:310)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:144)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	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 hudson.remoting.Engine$1$1.run(Engine.java:63)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: hudson.plugins.git.GitException: Command "clone --progress -o origin ssh://wheezy64b/var/cache/git/mwaite/bin.git C:\J\workspace\git-cli-ssh" returned status code 128:
      stdout: Cloning into 'C:\J\workspace\git-cli-ssh'...
      
      stderr: error: cannot spawn C:\Users\Alan\AppData\Local\Temp\ssh3783977685963347919.exe: No such file or directory
      fatal: unable to fork
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:981)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:920)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:64)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:308)
      	... 11 more
      ERROR: null
      Finished: FAILURE
      

          [JENKINS-20356] Git CLI cannot clone on Windows using GIT_SSH to set credentials when running as a service

          Mark Waite created issue -
          Mark Waite made changes -
          Component/s New: git-client [ 17423 ]
          Description Original: A git job configured to use the command line implementation with Git plugin 2.0 and git client plugin 1.4.6 fails to clone on Windows, but successfully clones on Linux.

          The problem seems to be that it is trying to configure an environment (setting SSH_PASS=echo) for the launched command, even though Windows does not use the same technique to pass environment variables to a process.

          I created the job by:

          0 - Configure a global ssh credential
          1 - Create a new job
          2 - Use a git ssh protocol URL (like ssh://wheezy64b/var/cache/git/mwaite/bin.git)
          3 - Select the correct ssh credential from the dropdown list
          4 - Add a build step (I used XShell "echo hello world")
          5 - Save the job
          6 - Run the job

          Stack trace on Windows:

          Started by user anonymous
          Building remotely on alan-pc in workspace C:\J\workspace\git-cli-ssh
          Cloning the remote Git repository
          Cloning repository ssh://wheezy64b/var/cache/git/mwaite/bin.git
          git --version
          git version 1.8.3.msysgit.0
          using GIT_SSH to set credentials Jenkins
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Could not clone ssh://wheezy64b/var/cache/git/mwaite/bin.git
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:310)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:144)
          at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          at hudson.remoting.Request$2.run(Request.java:326)
          at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          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 hudson.remoting.Engine$1$1.run(Engine.java:63)
          at java.lang.Thread.run(Unknown Source)
          Caused by: hudson.plugins.git.GitException: Command "clone --progress -o origin ssh://wheezy64b/var/cache/git/mwaite/bin.git C:\J\workspace\git-cli-ssh" returned status code 128:
          stdout: Cloning into 'C:\J\workspace\git-cli-ssh'...

          stderr: error: cannot spawn C:\Users\Alan\AppData\Local\Temp\ssh3783977685963347919.exe: No such file or directory
          fatal: unable to fork

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:981)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:920)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:64)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:308)
          ... 11 more
          ERROR: null
          Finished: FAILURE
          New: A git job configured to use the command line implementation with Git plugin 2.0 and git client plugin 1.4.6 fails to clone on Windows, but successfully clones on Linux.

          The problem seems to be that it is trying to configure an environment (setting SSH_PASS=echo) for the launched command, even though Windows does not use the same technique to pass environment variables to a process.

          I think there was a different behavior in prior versions of git-client.

          I created the job by:

          0 - Configure a global ssh credential
          1 - Create a new job
          2 - Use a git ssh protocol URL (like ssh://wheezy64b/var/cache/git/mwaite/bin.git)
          3 - Select the correct ssh credential from the dropdown list
          4 - Add a build step (I used XShell "echo hello world")
          5 - Save the job
          6 - Run the job

          Stack trace on Windows:

          Started by user anonymous
          Building remotely on alan-pc in workspace C:\J\workspace\git-cli-ssh
          Cloning the remote Git repository
          Cloning repository ssh://wheezy64b/var/cache/git/mwaite/bin.git
          git --version
          git version 1.8.3.msysgit.0
          using GIT_SSH to set credentials Jenkins
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Could not clone ssh://wheezy64b/var/cache/git/mwaite/bin.git
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:310)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:144)
          at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          at hudson.remoting.Request$2.run(Request.java:326)
          at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          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 hudson.remoting.Engine$1$1.run(Engine.java:63)
          at java.lang.Thread.run(Unknown Source)
          Caused by: hudson.plugins.git.GitException: Command "clone --progress -o origin ssh://wheezy64b/var/cache/git/mwaite/bin.git C:\J\workspace\git-cli-ssh" returned status code 128:
          stdout: Cloning into 'C:\J\workspace\git-cli-ssh'...

          stderr: error: cannot spawn C:\Users\Alan\AppData\Local\Temp\ssh3783977685963347919.exe: No such file or directory
          fatal: unable to fork

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:981)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:920)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:64)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:308)
          ... 11 more
          ERROR: null
          Finished: FAILURE
          Mark Waite made changes -
          Description Original: A git job configured to use the command line implementation with Git plugin 2.0 and git client plugin 1.4.6 fails to clone on Windows, but successfully clones on Linux.

          The problem seems to be that it is trying to configure an environment (setting SSH_PASS=echo) for the launched command, even though Windows does not use the same technique to pass environment variables to a process.

          I think there was a different behavior in prior versions of git-client.

          I created the job by:

          0 - Configure a global ssh credential
          1 - Create a new job
          2 - Use a git ssh protocol URL (like ssh://wheezy64b/var/cache/git/mwaite/bin.git)
          3 - Select the correct ssh credential from the dropdown list
          4 - Add a build step (I used XShell "echo hello world")
          5 - Save the job
          6 - Run the job

          Stack trace on Windows:

          Started by user anonymous
          Building remotely on alan-pc in workspace C:\J\workspace\git-cli-ssh
          Cloning the remote Git repository
          Cloning repository ssh://wheezy64b/var/cache/git/mwaite/bin.git
          git --version
          git version 1.8.3.msysgit.0
          using GIT_SSH to set credentials Jenkins
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Could not clone ssh://wheezy64b/var/cache/git/mwaite/bin.git
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:310)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:144)
          at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          at hudson.remoting.Request$2.run(Request.java:326)
          at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          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 hudson.remoting.Engine$1$1.run(Engine.java:63)
          at java.lang.Thread.run(Unknown Source)
          Caused by: hudson.plugins.git.GitException: Command "clone --progress -o origin ssh://wheezy64b/var/cache/git/mwaite/bin.git C:\J\workspace\git-cli-ssh" returned status code 128:
          stdout: Cloning into 'C:\J\workspace\git-cli-ssh'...

          stderr: error: cannot spawn C:\Users\Alan\AppData\Local\Temp\ssh3783977685963347919.exe: No such file or directory
          fatal: unable to fork

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:981)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:920)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:64)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:308)
          ... 11 more
          ERROR: null
          Finished: FAILURE
          New: A git job configured to use the command line implementation with Git plugin 2.0 and git client plugin 1.4.6 fails to clone on Windows, but successfully clones on Linux.

          The problem seems to be that it is trying to configure an environment (setting SSH_PASS=echo) for the launched command, even though Windows does not use the same technique to pass environment variables to a process.

          I think there was a different behavior in prior versions of git-client.

          I created the job by:

          0 - Configure a global ssh credential
          1 - Create a new job, restrict it to only run on Windows
          2 - Use a git ssh protocol URL (like ssh://wheezy64b/var/cache/git/mwaite/bin.git)
          3 - Select the correct ssh credential from the dropdown list
          4 - Add a build step (I used XShell "echo hello world")
          5 - Save the job
          6 - Run the job

          Stack trace on Windows:

          Started by user anonymous
          Building remotely on alan-pc in workspace C:\J\workspace\git-cli-ssh
          Cloning the remote Git repository
          Cloning repository ssh://wheezy64b/var/cache/git/mwaite/bin.git
          git --version
          git version 1.8.3.msysgit.0
          using GIT_SSH to set credentials Jenkins
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Could not clone ssh://wheezy64b/var/cache/git/mwaite/bin.git
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:310)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:151)
          at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:144)
          at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          at hudson.remoting.Request$2.run(Request.java:326)
          at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          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 hudson.remoting.Engine$1$1.run(Engine.java:63)
          at java.lang.Thread.run(Unknown Source)
          Caused by: hudson.plugins.git.GitException: Command "clone --progress -o origin ssh://wheezy64b/var/cache/git/mwaite/bin.git C:\J\workspace\git-cli-ssh" returned status code 128:
          stdout: Cloning into 'C:\J\workspace\git-cli-ssh'...

          stderr: error: cannot spawn C:\Users\Alan\AppData\Local\Temp\ssh3783977685963347919.exe: No such file or directory
          fatal: unable to fork

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:981)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:920)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:64)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:308)
          ... 11 more
          ERROR: null
          Finished: FAILURE

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          http://jenkins-ci.org/commit/git-client-plugin/8035439cc739df3b7814fdb8154b82309974e1a5
          Log:
          JENKINS-20356 windows-compliant GIT_SSH
          work in progress, failing now :

          Fetching upstream changes from git@github.com:cloudbees/test.git
          using GIT_SSH to set credentials
          FATAL: Failed to fetch from git@github.com:cloudbees/test.git
          hudson.plugins.git.GitException: Failed to fetch from git@github.com:cloudbees/test.git
          at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:617)
          at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:841)
          at hudson.plugins.git.GitSCM.checkout(GitSCM.java:866)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
          at hudson.model.Run.execute(Run.java:1502)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:236)
          Caused by: hudson.plugins.git.GitException: Command "fetch -t git@github.com:cloudbees/test.git +refs/heads/:refs/remotes/origin/" returned status code 128:
          stdout: Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information

          stderr: fatal: protocol error: bad line length character:
          C:
          select: Bad file number

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java http://jenkins-ci.org/commit/git-client-plugin/8035439cc739df3b7814fdb8154b82309974e1a5 Log: JENKINS-20356 windows-compliant GIT_SSH work in progress, failing now : Fetching upstream changes from git@github.com:cloudbees/test.git using GIT_SSH to set credentials FATAL: Failed to fetch from git@github.com:cloudbees/test.git hudson.plugins.git.GitException: Failed to fetch from git@github.com:cloudbees/test.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:617) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:841) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:866) at hudson.model.AbstractProject.checkout(AbstractProject.java:1256) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494) at hudson.model.Run.execute(Run.java:1502) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:236) Caused by: hudson.plugins.git.GitException: Command "fetch -t git@github.com:cloudbees/test.git +refs/heads/ :refs/remotes/origin/ " returned status code 128: stdout: Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information stderr: fatal: protocol error: bad line length character: C: select: Bad file number

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          http://jenkins-ci.org/commit/git-client-plugin/ba88496975ee2ca04107cfcc0e5b476c53417d66
          Log:
          JENKINS-20356 windows-compliant GIT_SSH

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java http://jenkins-ci.org/commit/git-client-plugin/ba88496975ee2ca04107cfcc0e5b476c53417d66 Log: JENKINS-20356 windows-compliant GIT_SSH

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          http://jenkins-ci.org/commit/git-client-plugin/6a44f4acd99d1508945c029d4d92ab20762e4a02
          Log:
          JENKINS-20356 windows-compliant GIT_SSH

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java http://jenkins-ci.org/commit/git-client-plugin/6a44f4acd99d1508945c029d4d92ab20762e4a02 Log: JENKINS-20356 windows-compliant GIT_SSH
          Nicolas De Loof made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Is there a work around for this issue, or is a code release required in order for this to work. I am getting the same error when trying to connect to a repository in a job configuration.

          Roland Whitley added a comment - Is there a work around for this issue, or is a code release required in order for this to work. I am getting the same error when trying to connect to a repository in a job configuration.

          Mark Waite added a comment -

          The only alternatives I've discovered have required that I switch the URL to something other than an ssh URL.

          Mark Waite added a comment - The only alternatives I've discovered have required that I switch the URL to something other than an ssh URL.

          Roland Whitley added a comment - - edited

          Thanks, unfortunately I have not been very successful with gitlab and http. Commits have usually exceeded size limitations. Did you mention that this was a recent change and prior releases did not behave like this. Is there a version that I can roll back to that would bypass this until this fix is released. I only want to consider forking the branch as a final option.

          Roland Whitley added a comment - - edited Thanks, unfortunately I have not been very successful with gitlab and http. Commits have usually exceeded size limitations. Did you mention that this was a recent change and prior releases did not behave like this. Is there a version that I can roll back to that would bypass this until this fix is released. I only want to consider forking the branch as a final option.

            Unassigned Unassigned
            markewaite Mark Waite
            Votes:
            5 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: