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

Fail to clone a repository on Windows

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
      None
    • Environment:
      Platform: All, OS: Windows XP

      Description

      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
      occurs:

      started
      Checkout (clone)
      Cloning repository C:/sistemas_ruby/teste
      $ git clone C:/sistemas_ruby/teste "/C:/Documents and Settings/Antonio.HOME-
      2983D23F4B/.hudson/jobs/Teste/workspace"
      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.checkout(AbstractBuild.java:264)
      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:

      if(workspace.isRemote())
      args.add(source, workspace.toURI().getPath());
      else{
      final ArgumentListBuilder argsTmp = args;
      final String sourceTmp = source;
      args = workspace.act(new FileCallable<ArgumentListBuilder>() {
      public ArgumentListBuilder invoke(File workspace, VirtualChannel
      channel)
      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.

        Activity

        Hide
        scm_issue_link SCM/JIRA link daemon added a comment -

        Code changed in hudson
        User: : jbq
        Path:
        trunk/hudson/plugins/git/src/main/java/hudson/plugins/git/GitAPI.java
        http://fisheye4.cenqua.com/changelog/hudson/?cs=14143
        Log:
        [FIXED JENKINS-2762] Fail to clone a repository on Windows

        Show
        scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : jbq Path: trunk/hudson/plugins/git/src/main/java/hudson/plugins/git/GitAPI.java http://fisheye4.cenqua.com/changelog/hudson/?cs=14143 Log: [FIXED JENKINS-2762] Fail to clone a repository on Windows
        Hide
        mdonohue mdonohue added a comment -
            • Issue 3746 has been marked as a duplicate of this issue. ***
        Show
        mdonohue mdonohue added a comment - Issue 3746 has been marked as a duplicate of this issue. ***

          People

          • Assignee:
            jbq jbq
            Reporter:
            acmarques acmarques
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: