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

Extraneous Forward-Slash in ssh:// path to repository

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins version 1.598; Git plugin 2.3.4

      The SO question describes my exact problem down to the log file: http://stackoverflow.com/questions/27786733/why-is-the-git-plugin-for-jenkins-rewriting-my-local-git-repo-url-with-extra-sla

      [Repost Summary]
      -----------------------
      I'm having an issue right now trying to set up a Jenkins job (on one Windows server) to monitor an internal Git repo located on a Gitosis server (on a different Windows server).

      The url looks like this: ssh://git@192.168.0.1:relative_path/repo.git (real values replaced for security, also the relative path will not work with a '~/', it only works without a leading '/').

      When running git clone from the command line with the url, everything comes out fine.

      When configuring a Git SCM in the Jenkins job it is able to run an ls-remote command (this confirms that the ssh keys are properly configured for the Jenkins instance).

      However when the job executes, the url appears to be rewritten with an additional forward slash which causes the clone command to fail.

      Started by user Meh
      [EnvInject] - Loading node environment variables.
      Building in workspace D:\local_repo_test
      > git.exe rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
      > git.exe config remote.origin.url ssh:///git@192.168.0.1:relative_path/repo.git # timeout=10
      Fetching upstream changes from ssh:///git@192.168.0.1:relative_path/repo.git
      > git.exe --version # timeout=10
      > git.exe -c core.askpass=true fetch --tags --progress ssh:///git@192.168.0.1:relative_path/repo.git +refs/heads/:refs/remotes/origin/
      ERROR: Error fetching remote repo 'origin'
      ERROR: Error fetching remote repo 'origin'
      Finished: FAILURE
      It's the '///' that bothers me. Has anyone seen anything like this?

      Any help on this would be appreciated.

          [JENKINS-26680] Extraneous Forward-Slash in ssh:// path to repository

          The bug does not only manifest itself when using relative repositories, but also when using variables to compose a git URI. For example with the Gerrit plugin, you may want to use a git uri such as ssh://$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT. In this case, the URI will be rewritten with a triple slash, leading to a failure with most git distributions.

          Jerome Oufella added a comment - The bug does not only manifest itself when using relative repositories, but also when using variables to compose a git URI. For example with the Gerrit plugin, you may want to use a git uri such as ssh://$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT. In this case, the URI will be rewritten with a triple slash, leading to a failure with most git distributions.

          Mark Waite added a comment -

          jero I don't understand how the rewrite is happening in your case, since you're using the platform portable form of the URL (assuming GERRIT_PORT is either a port number or the name of a port as listed in /etc/services). The other entries in this bug report are asking for a URI syntax which is not platform portable, but as far as I can tell, your URI syntax is platform portable.

          Are you sure that your case $GERRIT_PORT actually is evaluating to a port number?

          Mark Waite added a comment - jero I don't understand how the rewrite is happening in your case, since you're using the platform portable form of the URL (assuming GERRIT_PORT is either a port number or the name of a port as listed in /etc/services). The other entries in this bug report are asking for a URI syntax which is not platform portable, but as far as I can tell, your URI syntax is platform portable. Are you sure that your case $GERRIT_PORT actually is evaluating to a port number?

          Jerome Oufella added a comment - - edited

          Hi markewaite, yes I can confirm that from the job instance's console log. As you can see below, the URL is rewritten using an extra slash.

          Job's git repository URL: ssh://$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT
          Result:

          ...
          Fetching upstream changes from ssh:///obfuscatedhostname.com:29419/some/repo
           > git --version # timeout=10
           > git -c core.askpass=true fetch --tags --progress ssh:///obfuscatedhostname.com:29419/some/repo +refs/heads/*:refs/remotes/origin/*
          ERROR: Error cloning remote repo 'origin'
          hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress ssh:///obfuscatedhostname.com:29419/some/repo +refs/heads/*:refs/remotes/origin/*" returned status code 128:
          stdout: 
          stderr: ssh: Could not resolve hostname : Name or service not known
          fatal: Could not read from remote repository.
          ...
          

          EDIT: fix code block

          Jerome Oufella added a comment - - edited Hi markewaite , yes I can confirm that from the job instance's console log. As you can see below, the URL is rewritten using an extra slash. Job's git repository URL: ssh://$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT Result: ... Fetching upstream changes from ssh:///obfuscatedhostname.com:29419/some/repo > git --version # timeout=10 > git -c core.askpass=true fetch --tags --progress ssh:///obfuscatedhostname.com:29419/some/repo +refs/heads/*:refs/remotes/origin/* ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress ssh:///obfuscatedhostname.com:29419/some/repo +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: ssh: Could not resolve hostname : Name or service not known fatal: Could not read from remote repository. ... EDIT: fix code block

          Note, this was tested with the following configuration:

          • Jenkins 1.643
          • Git plugin 2.4.1
          • Git client plugin 1.19.1

          Jerome Oufella added a comment - Note, this was tested with the following configuration: Jenkins 1.643 Git plugin 2.4.1 Git client plugin 1.19.1

          Mark Waite added a comment -

          Thanks for the further clarification. I think I see the same condition you're seeing in my test job.

          If I create a test URI that includes the port number (like ssh://wheezy64b.markwaite.net:45022/var/lib/git/mwaite/bin.git) then the clone works.

          If I create a parameterized test job with PORT_NUMBER as the parameter and assign it a value of 45022, and reference that port number in the URL, then the clone fails. It is as though the rewrite is somehow involved in the code path that expands that parameter.

          Mark Waite added a comment - Thanks for the further clarification. I think I see the same condition you're seeing in my test job. If I create a test URI that includes the port number (like ssh://wheezy64b.markwaite.net:45022/var/lib/git/mwaite/bin.git) then the clone works. If I create a parameterized test job with PORT_NUMBER as the parameter and assign it a value of 45022, and reference that port number in the URL, then the clone fails. It is as though the rewrite is somehow involved in the code path that expands that parameter.

          Ion Iovu added a comment -

          The problem seems to be in the jgit dependency.

          A bug has been logged at https://bugs.eclipse.org/bugs/show_bug.cgi?id=519187

          I referenced this bug in that report, so as to give an idea about what use case the bug affects.

          Ion Iovu added a comment - The problem seems to be in the jgit dependency. A bug has been logged at https://bugs.eclipse.org/bugs/show_bug.cgi?id=519187 I referenced this bug in that report, so as to give an idea about what use case the bug affects.

          Mark Waite added a comment -

          If the issue truly is in the JGit dependency, then git client plugin 3.0.0-beta versions (available now from the experimental update center) should have it fixed. They include a newer version of JGit and that newer version should include the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=519187

          Mark Waite added a comment - If the issue truly is in the JGit dependency, then git client plugin 3.0.0-beta versions (available now from the experimental update center) should have it fixed. They include a newer version of JGit and that newer version should include the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=519187

          a b added a comment - - edited

          I am experiencing this issue and cannot figure out how to work around it.  Attempting to use the following syntax to checkout a repo in a declarative pipeline job. It adds the extra slash when using the ssh:// prefix and fails another way without it. Are there other options?

          dir("testing-workspace/") {
            git branch: 'master',
            credentialsId: 'bitbucket_ssh',
            url: 'ssh://git@bitbucket.org:<company>/<repo_name>.git'
          }

           Error (sensitive data obfuscated) 

          ssh:///git@bitbucket.org:****/******.git
          +refs/heads/*:refs/remotes/origin/*" returned status code 128:
          stdout: 
          stderr: ssh: Could not resolve hostname : Name or service not known
          fatal: Could not read from remote repository.
          

          Jenkins: 2.207

          Git plugin: 4.0.0

          a b added a comment - - edited I am experiencing this issue and cannot figure out how to work around it.  Attempting to use the following syntax to checkout a repo in a declarative pipeline job. It adds the extra slash when using the ssh:// prefix and fails another way without it. Are there other options? dir( "testing-workspace/" ) { git branch:  'master' , credentialsId:  'bitbucket_ssh' , url:  'ssh: //git@bitbucket.org:<company>/<repo_name>.git' }  Error (sensitive data obfuscated)  ssh: ///git@bitbucket.org:****/******.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: ssh: Could not resolve hostname : Name or service not known fatal: Could not read from remote repository. Jenkins: 2.207 Git plugin: 4.0.0

          Mark Waite added a comment - - edited

          stuck_tech I believe the syntax you're using for the ssh URL is incorrect. Refer to the first comment in this report for a detailed description why that URL syntax is incorrect.

          You are separating the hostname and the organization name with a ':' character. That is ambiguous in the URL specification for an ssh URL. The text to the right of the colon could be interpreted as a service name or as a port number.

          Alternatives include:

          Use the scp syntax:

          git@bitbucket.org:markewaite/bin.git
          

          Alternately, use the ssh syntax:

          ssh://git@gitbucket.org/markewaite/bin.git
          

          Mark Waite added a comment - - edited stuck_tech I believe the syntax you're using for the ssh URL is incorrect. Refer to the first comment in this report for a detailed description why that URL syntax is incorrect. You are separating the hostname and the organization name with a ':' character. That is ambiguous in the URL specification for an ssh URL. The text to the right of the colon could be interpreted as a service name or as a port number. Alternatives include: Use the scp syntax: git@bitbucket.org:markewaite/bin.git Alternately, use the ssh syntax: ssh://git@gitbucket.org/markewaite/bin.git

          Gordon Jess added a comment -

          jero, I also ran into this issue using Gerrit parameters to compose the url.  Replacing "ssh" with $GERRIT_SCHEME fixed it, strangely!

          Gordon Jess added a comment - jero , I also ran into this issue using Gerrit parameters to compose the url.  Replacing "ssh" with $GERRIT_SCHEME fixed it, strangely!

            Unassigned Unassigned
            nhvirtuoso Bryan Garretson
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: