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

Credentialed Git fetch fails on Windows if workspace path contains a space

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • git-plugin
    • None
    • Jenkins 2.57
      git plugin 3.3.0

      Since last update to jenkins 2.57 with git-plugin 3.3.0, jobs are failing fetching git repositories when job name contains space. Trace is :

      Building remotely on Platform-BDXWEB037 (platform2) in workspace E:\Jenkins\workspace\Projet Platform Environment Deployment (ANY)
      > git.exe rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
      > git.exe config remote.origin.url http://git.intraxiti.com/deployment/PlatformPublisherV2.git # timeout=10
      Cleaning workspace
      > git.exe rev-parse --verify HEAD # timeout=10
      Resetting working tree
      > git.exe reset --hard # timeout=10
      > git.exe clean -fdx # timeout=10
      Fetching upstream changes from http://git.intraxiti.com/deployment/PlatformPublisherV2.git
      > git.exe --version # timeout=10
      using GIT_ASKPASS to set credentials Jenkins User for GitLab
      > git.exe fetch --tags --progress http://git.intraxiti.com/deployment/PlatformPublisherV2.git +refs/heads/:refs/remotes/origin/
      ERROR: Timeout after 10 minutes
      ERROR: Error fetching remote repo 'origin'
      hudson.plugins.git.GitException: Failed to fetch from http://git.intraxiti.com/deployment/PlatformPublisherV2.git
      at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:809)
      at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1076)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107)
      at hudson.scm.SCM.checkout(SCM.java:495)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1281)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
      at hudson.model.Run.execute(Run.java:1735)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:405)
      Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress http://git.intraxiti.com/deployment/PlatformPublisherV2.git +refs/heads/:refs/remotes/origin/" returned status code -1:
      stdout:
      *stderr: 'E:\Jenkins\workspace\Projet' is not recognized as an internal or external command,
      operable program or batch file.*

      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1866)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1585)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
      at hudson.remoting.UserRequest.perform(UserRequest.java:121)
      at hudson.remoting.UserRequest.perform(UserRequest.java:49)
      at hudson.remoting.Request$2.run(Request.java:325)
      at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      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:69)
      at java.lang.Thread.run(Unknown Source)
      at ......remote call to Channel to /172.18.1.9(Native Method)
      at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
      at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
      at hudson.remoting.Channel.call(Channel.java:830)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
      at sun.reflect.GeneratedMethodAccessor486.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
      at com.sun.proxy.$Proxy122.execute(Unknown Source)
      at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:807)
      ... 11 more
      ERROR: null

      Renaming the job is a workaround but implies to update all scripts and mechanisms linked to this job (script that trigger the job build for instance). This is really annoying.

          [JENKINS-43931] Credentialed Git fetch fails on Windows if workspace path contains a space

          Mark Waite added a comment - - edited

          As far as I can tell from my experiments, this bug is only visible if private key authentication to the repository (repo URL with scp syntax or ssh syntax) and a passphrase secured private key on windows. If any one of those conditions is removed (http repo URL with username / password, or remove the passphrase from the private key, or run the build on Linux), then the bug is not visible.

          It is a bug, but that additional information may help users avoid the issue until a fix is available.

          Mark Waite added a comment - - edited As far as I can tell from my experiments, this bug is only visible if private key authentication to the repository (repo URL with scp syntax or ssh syntax) and a passphrase secured private key on windows. If any one of those conditions is removed (http repo URL with username / password, or remove the passphrase from the private key, or run the build on Linux), then the bug is not visible. It is a bug, but that additional information may help users avoid the issue until a fix is available.

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/CredentialsTest.java
          http://jenkins-ci.org/commit/git-client-plugin/ab1ad21e4bbab4f03fca23f3f331493769370c20
          Log:
          JENKINS-43931 support private keys w/passphrase in Windows dirs with spaces

          The temporary file protection code (correctly) prefers to place
          sensitive temporary files near the workspace rather than placing them
          in the system temporary directory. The Windows git implementation
          (through at least git 2.12.2) fails to authenticate if the value of
          GIT_SSH is a path which includes a space.

          If the workspace temporary directory name contains a space, the system
          temporary directory will be used instead. There is already code in
          the CliGitAPIImpl class which writes a warning if the system temporary
          directory includes a space in its path.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/CredentialsTest.java http://jenkins-ci.org/commit/git-client-plugin/ab1ad21e4bbab4f03fca23f3f331493769370c20 Log: JENKINS-43931 support private keys w/passphrase in Windows dirs with spaces The temporary file protection code (correctly) prefers to place sensitive temporary files near the workspace rather than placing them in the system temporary directory. The Windows git implementation (through at least git 2.12.2) fails to authenticate if the value of GIT_SSH is a path which includes a space. If the workspace temporary directory name contains a space, the system temporary directory will be used instead. There is already code in the CliGitAPIImpl class which writes a warning if the system temporary directory includes a space in its path.

          Mark Waite added a comment - - edited

          Fixed in git client plugin 2.4.5, released 29 Apr 2017

          Mark Waite added a comment - - edited Fixed in git client plugin 2.4.5, released 29 Apr 2017

          Paulo Pires added a comment -

          Hi markewaite, I'm still receiving a similar error message using git client plugin version 2.4.5 and my project name don't have space in it. 

           

          Building in workspace C:\Program Files (x86)\Jenkins\jobs\eTCMGeraNovaVersao\workspace
          Cloning the remote Git repository
          Cloning repository http://Git/asi/eTCM.git
          git.exe init C:\Program Files (x86)\Jenkins\jobs\eTCMGeraNovaVersao\workspace # timeout=10
          Fetching upstream changes from http://Git/asi/eTCM.git
          git.exe --version # timeout=10
          using GIT_ASKPASS to set credentials Usuário para acessar o Gitlab no servidor Git
          git.exe fetch --tags --progress http://Git/asi/eTCM.git +refs/heads/:refs/remotes/origin/
          ERROR: Timeout after 10 minutes
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress http://Git/asi/eTCM.git +refs/heads/:refs/remotes/origin/" returned status code -1:
          stdout:
          stderr: 'C:\Program' is not recognized as an internal or external command,
          operable program or batch file.

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1877)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1596)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:545)
          at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1067)
          at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107)
          at hudson.scm.SCM.checkout(SCM.java:496)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1281)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
          at hudson.model.Run.execute(Run.java:1728)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:405)
          ERROR: null

          Paulo Pires added a comment - Hi markewaite , I'm still receiving a similar error message using git client plugin version 2.4.5 and my project name don't have space in it.    Building in workspace C:\Program Files (x86)\Jenkins\jobs\eTCMGeraNovaVersao\workspace Cloning the remote Git repository Cloning repository http://Git/asi/eTCM.git git.exe init C:\Program Files (x86)\Jenkins\jobs\eTCMGeraNovaVersao\workspace # timeout=10 Fetching upstream changes from http://Git/asi/eTCM.git git.exe --version # timeout=10 using GIT_ASKPASS to set credentials Usuário para acessar o Gitlab no servidor Git git.exe fetch --tags --progress http://Git/asi/eTCM.git +refs/heads/ :refs/remotes/origin/ ERROR: Timeout after 10 minutes ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress http://Git/asi/eTCM.git +refs/heads/ :refs/remotes/origin/ " returned status code -1: stdout: stderr: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1877) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1596) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:545) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1067) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107) at hudson.scm.SCM.checkout(SCM.java:496) at hudson.model.AbstractProject.checkout(AbstractProject.java:1281) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1728) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:405) ERROR: null

          Mark Waite added a comment - - edited

          paulofgp the path to your workspace includes a space, since the git init command is:

          git.exe init C:\Program Files (x86)\Jenkins\jobs\eTCMGeraNovaVersao\workspace
          

          Since you're using http protocol, I assume you are authenticating with a username and password (rather than with a passphrase protected private key as described in this bug report). Can you confirm that you're using a username / password combination?

          The username / password path was not modified in the git client plugin 2.4.5 release because I did not see the problem on that path. The only path where I saw the problem was in the private key with passphrase path. However, now that I read the bug report again, the original submitter was using a username / password with http. I'll need to do further testing with the username / password path to see if I can duplicate the problem.

          I've created a snapshot build which contains the one line modification to handle username / password cases. Could you test drive it to see if it resolves your issue?

          Mark Waite added a comment - - edited paulofgp the path to your workspace includes a space, since the git init command is: git.exe init C:\Program Files (x86)\Jenkins\jobs\eTCMGeraNovaVersao\workspace Since you're using http protocol, I assume you are authenticating with a username and password (rather than with a passphrase protected private key as described in this bug report). Can you confirm that you're using a username / password combination? The username / password path was not modified in the git client plugin 2.4.5 release because I did not see the problem on that path. The only path where I saw the problem was in the private key with passphrase path. However, now that I read the bug report again, the original submitter was using a username / password with http. I'll need to do further testing with the username / password path to see if I can duplicate the problem. I've created a snapshot build which contains the one line modification to handle username / password cases. Could you test drive it to see if it resolves your issue?

          Paulo Pires added a comment -

          I'm really using username and password.

          I tested your snapshot build and it worked.

          Tks for your help.

          Paulo Pires added a comment - I'm really using username and password. I tested your snapshot build and it worked. Tks for your help.

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          http://jenkins-ci.org/commit/git-client-plugin/4f27a7010ea9d2aa8516edd44791561f99792d41
          Log:
          JENKINS-43931 Allow username/password workspaces with space in path

          Prior fix only handled ssh passphrase protected private keys

          Note that the issue is only visible on Windows and only with workspaces
          whose full path includes a space.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java http://jenkins-ci.org/commit/git-client-plugin/4f27a7010ea9d2aa8516edd44791561f99792d41 Log: JENKINS-43931 Allow username/password workspaces with space in path Prior fix only handled ssh passphrase protected private keys Note that the issue is only visible on Windows and only with workspaces whose full path includes a space.

          Ryan Hinton added a comment -

          Hi Mark, I just updated with your SNAPSHOT and it worked.  Thank you.

          Ryan Hinton added a comment - Hi Mark, I just updated with your SNAPSHOT and it worked.  Thank you.

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/test/java/org/jenkinsci/plugins/gitclient/CredentialsTest.java
          http://jenkins-ci.org/commit/git-client-plugin/5c74414a6ef50488e9006d83f127a69b6a7b8da0
          Log:
          Test special characters in credentials workspace path

          JENKINS-44041 - Windows authenticated git checkout fails if '(' or ')' in path to workspace
          JENKINS-43931 - Windows authenticated git checkout fails if ' ' in path to workspace
          JENKINS-44127 - Authenticated git checkout fails if '%' in path to workspace (Windows & Linux)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/test/java/org/jenkinsci/plugins/gitclient/CredentialsTest.java http://jenkins-ci.org/commit/git-client-plugin/5c74414a6ef50488e9006d83f127a69b6a7b8da0 Log: Test special characters in credentials workspace path JENKINS-44041 - Windows authenticated git checkout fails if '(' or ')' in path to workspace JENKINS-43931 - Windows authenticated git checkout fails if ' ' in path to workspace JENKINS-44127 - Authenticated git checkout fails if '%' in path to workspace (Windows & Linux)

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          http://jenkins-ci.org/commit/git-client-plugin/8a2ddf222f4463e2458e387121bf8d4c7840c37a
          Log:
          Fix special characters bugs in credentials workspace path

          JENKINS-44041 - Windows authenticated git checkout fails if '(' or ')' in path to workspace
          JENKINS-43931 - Windows authenticated git checkout fails if ' ' in path to workspace
          JENKINS-44127 - Authenticated git checkout fails if '%' in path to workspace (Windows & Linux)

          Also safeguards against use for "`" (grave) in a workspace path.
          Jenkins already guards against that, but the added safety check is low
          cost and passes the credentials tests.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java http://jenkins-ci.org/commit/git-client-plugin/8a2ddf222f4463e2458e387121bf8d4c7840c37a Log: Fix special characters bugs in credentials workspace path JENKINS-44041 - Windows authenticated git checkout fails if '(' or ')' in path to workspace JENKINS-43931 - Windows authenticated git checkout fails if ' ' in path to workspace JENKINS-44127 - Authenticated git checkout fails if '%' in path to workspace (Windows & Linux) Also safeguards against use for "`" (grave) in a workspace path. Jenkins already guards against that, but the added safety check is low cost and passes the credentials tests.

            markewaite Mark Waite
            splashnenen Alexandre Aubert
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: