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

Fail to clone a repository on Windows


    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • None
    • Platform: All, OS: Windows XP

      We've found an issue using Hudson + Git plugin on Windows: when the plugin tries
      to execute a clone in a repository (local or remote), the following error

      Checkout (clone)
      Cloning repository C:/sistemas_ruby/teste
      $ git clone C:/sistemas_ruby/teste "/C:/Documents and Settings/Antonio.HOME-
      fatal: could not create leading directories of '/C:/Documents and
      Settings/Antonio.HOME-2983D23F4B/.hudson/jobs/Teste/workspace': Invalid argument
      FATAL: Clone returned an error code
      hudson.plugins.git.GitException: Clone returned an error code
      at hudson.plugins.git.GitAPI.clone(GitAPI.java:142)
      at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:264)
      at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:235)
      at hudson.FilePath.act(FilePath.java:389)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:235)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:666)
      at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:238)
      at hudson.model.Run.run(Run.java:823)
      at hudson.matrix.MatrixBuild.run(MatrixBuild.java:100)
      at hudson.model.ResourceController.execute(ResourceController.java:70)
      at hudson.model.Executor.run(Executor.java:90)

      The problem is the first slash on the path of the workspace ("/C:/Documents…").
      I guess that on Linux this shouldn't be a problem, but on windows this slash
      causes an error.

      I downloaded the sources from Maven browser (http://www.mvnbrowser.com/artifact-
      details.html?groupId=org.jvnet.hudson.plugins&artifactId=git&version=0.5 ) and
      found that the problem occurs in the class GitAPI.java, in the following line of
      the clone method:

      args.add(source, workspace.toURI().getPath());

      It seems that the method toURI() of the FilePath class always returns a string
      beginning with a slash. So, I've changed this line to the following:

      args.add(source, workspace.toURI().getPath());
      final ArgumentListBuilder argsTmp = args;
      final String sourceTmp = source;
      args = workspace.act(new FileCallable<ArgumentListBuilder>() {
      public ArgumentListBuilder invoke(File workspace, VirtualChannel
      throws IOException

      { return argsTmp.add(sourceTmp, workspace.toString()); }


      And it works pretty well for me, at least in a windows environment.

      I would like to ask you to please verify if this modification is correct and, if
      possible, to include it in a next version of the plugin.

            jbq jbq
            acmarques acmarques
            0 Vote for this issue
            0 Start watching this issue