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

"Error cloning remote repo 'origin'" with username:password@bitbucket.org URLs

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • None
    • Jenkins 1.598
      Git 1.9.5.msysgit.0

      Using the current version of git-client-plugin 1.15.0 and git-plugin 2.3.4 the cloning of a private bitbucket.org repository does not work.
      It used to work with git-client-plugin 1.3.0 and git-plugin 1.5.0.

      I created a new "Free Style" job, entering only a Git SCM with https://username:password@bitbucket.org/user/repository.git as "Repository URL" leaving everything else as default.
      I'm aware of the credentials functionality, but I need to use https://username:password@bitbucket.org/user/repository.git URL syntax, for otherwise certain post build steps will not work.

      This is the output I get:

      Started by user Flavio Donzé
      Building in workspace C:\data\jenkins\workspace\workspace\git_test
      Cloning the remote Git repository
      Cloning repository https://username:password@bitbucket.org/user/repository.git
      > C:/Progra~2/Git/bin/git.exe init C:\data\jenkins\workspace\workspace\git_test # timeout=10
      Fetching upstream changes from https://username@bitbucket.org/user/repository.git
      > C:/Progra~2/Git/bin/git.exe --version # timeout=10
      > C:/Progra~2/Git/bin/git.exe -c core.askpass=true fetch --tags --progress https://username@bitbucket.org/user/repository.git +refs/heads/:refs/remotes/origin/
      ERROR: Error cloning remote repo 'origin'
      ERROR: Error cloning remote repo 'origin'
      Finished: FAILURE

          [JENKINS-26757] "Error cloning remote repo 'origin'" with username:password@bitbucket.org URLs

          Flavio Donzé created issue -

          Mark Waite added a comment - - edited

          Can you use the work around described in JENKINS-22694?

          Register that user name and password in a credential, then use that credential in the job definition (rather than embedding the user name and password in the URL).

          Alternately, can you use the work around of using an ssh URL to access that same repository instead of using an https URL?

          Alternately, can you somehow include the username and password information in your downstream tasks using another technique?

          Another possibility might be to try using JGit as the git implementation, instead of command line git.

          Mark Waite added a comment - - edited Can you use the work around described in JENKINS-22694 ? Register that user name and password in a credential, then use that credential in the job definition (rather than embedding the user name and password in the URL). Alternately, can you use the work around of using an ssh URL to access that same repository instead of using an https URL? Alternately, can you somehow include the username and password information in your downstream tasks using another technique? Another possibility might be to try using JGit as the git implementation, instead of command line git.

          Flavio Donzé added a comment -

          As I stated in the bug I need to use this URL syntax, because of certain post build processors.

          I tried the ssh URL and JGit, this are my test results:

          Using JGit and https://
          Failed to connect to repository : org.eclipse.jgit.errors.TransportException: https://username@bitbucket.org/user/repository.git: not authorized

          Using JGit and git://
          Failed to connect to repository : org.eclipse.jgit.errors.NotSupportedException: URI not supported: git://username@bitbucket.org/user/repository.git

          Using JGit and ssh://
          No error message, but the build runs in a endless loop.

          Using Git command line and ssh://
          Failed to connect to repository : Command "C:/Progra~2/Git/bin/git.exe -c core.askpass=true ls-remote -h ssh://username@bitbucket.org/user/repository.gitHEAD" returned status code 128:
          stdout:
          stderr: Unable to open connection:
          Host does not existfatal: Could not read from remote repository.

          Please make sure you have the correct access rights and the repository exists

          Flavio Donzé added a comment - As I stated in the bug I need to use this URL syntax, because of certain post build processors. I tried the ssh URL and JGit, this are my test results: Using JGit and https:// Failed to connect to repository : org.eclipse.jgit.errors.TransportException: https://username@bitbucket.org/user/repository.git: not authorized Using JGit and git:// Failed to connect to repository : org.eclipse.jgit.errors.NotSupportedException: URI not supported: git://username@bitbucket.org/user/repository.git Using JGit and ssh:// No error message, but the build runs in a endless loop. Using Git command line and ssh:// Failed to connect to repository : Command "C:/Progra~2/Git/bin/git.exe -c core.askpass=true ls-remote -h ssh://username@bitbucket.org/user/repository.gitHEAD" returned status code 128: stdout: stderr: Unable to open connection: Host does not existfatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
          Mark Waite made changes -
          Link New: This issue duplicates JENKINS-24368 [ JENKINS-24368 ]

          Mark Waite added a comment - - edited

          I confirmed with git client plugin 1.16.1 and git plugin 2.3.5 that a private bitbucket repository with embedded user name and password fails to fetch. The remote.origin.url is correctly set in the workspace repository and is usable by "git remote update".

          If I login to that slave, change directory to that repository and perform a "git remote update origin", the changes are fetched into the repository from the bitbucket URL.

          I think that shows the problem is specific to a private bitbucket repository with https protocol and embedded user name and password from a Jenkins job. Change any one of those items (for example, use a credential instead of embedding the user name/password, or use a public bitbucket repository, or use a different protocol) and it seems to work. I realize none of those alternatives meet the needs of flaviodonze, but I now better understand the symptoms of the bug.

          Mark Waite added a comment - - edited I confirmed with git client plugin 1.16.1 and git plugin 2.3.5 that a private bitbucket repository with embedded user name and password fails to fetch. The remote.origin.url is correctly set in the workspace repository and is usable by "git remote update". If I login to that slave, change directory to that repository and perform a "git remote update origin", the changes are fetched into the repository from the bitbucket URL. I think that shows the problem is specific to a private bitbucket repository with https protocol and embedded user name and password from a Jenkins job. Change any one of those items (for example, use a credential instead of embedding the user name/password, or use a public bitbucket repository, or use a different protocol) and it seems to work. I realize none of those alternatives meet the needs of flaviodonze , but I now better understand the symptoms of the bug.

          Nick Maynard added a comment -

          Also seeing this.
          This may be a recurrence of this bug - JENKINS-20533.

          Nick Maynard added a comment - Also seeing this. This may be a recurrence of this bug - JENKINS-20533 .

          Mark Waite added a comment -

          nickcmaynard I don't think that it is a recurrence of JENKINS-20533, since that bug was fixed by deletion of a problematic code path, and that code path has definitely not been reintroduced.

          Unfortunately, all that means is that I don't know where the bug is, only where it likely isn't.

          Mark Waite added a comment - nickcmaynard I don't think that it is a recurrence of JENKINS-20533 , since that bug was fixed by deletion of a problematic code path, and that code path has definitely not been reintroduced. Unfortunately, all that means is that I don't know where the bug is, only where it likely isn't.

          Nick Maynard added a comment -

          I'm seeing this on a different host than Bitbucket - namely IBM's DevOps Services Git hosting.
          The URLs for this look something like https://email%40domain.tld:password@hub.jazz.net/git/blah/blah

          Nick Maynard added a comment - I'm seeing this on a different host than Bitbucket - namely IBM's DevOps Services Git hosting. The URLs for this look something like https://email%40domain.tld:password@hub.jazz.net/git/blah/blah

          I've the same problem and in one case it appeared in jobs running on 'master'. What solved problem in this case was putting ssh key in <jenkins user home directory>/.ssh/id_rsa. So it seems it's a ssh access issue. What's bad - there are no records about the problem in jenkins log.

          Now I have the second case. The same symptoms but on JClouds provided slaves and I wonder what should I do.

          Alexander Uvizhev added a comment - I've the same problem and in one case it appeared in jobs running on 'master'. What solved problem in this case was putting ssh key in <jenkins user home directory>/.ssh/id_rsa. So it seems it's a ssh access issue. What's bad - there are no records about the problem in jenkins log. Now I have the second case. The same symptoms but on JClouds provided slaves and I wonder what should I do.

          Mark Waite added a comment -

          uvizhe I am surprised that you're having a problem which is specific to bitbucket and a username / password embedded directly in the URL. From other bug reports, it seems you're using GitHub Enterprise, not bitbucket.

          Up to this time, I've only heard of this problem affecting bitbucket users, and only with the user name and password embedded directly into the URL.

          If you resolved the issue by adding .ssh/id_rsa to the home directory of your Jenkins user, then you should also be able to use the Jenkins credentials plugin to insert that same private key into Jenkins, then reference that private key from the Git configuration within the specific job using that repository.

          Mark Waite added a comment - uvizhe I am surprised that you're having a problem which is specific to bitbucket and a username / password embedded directly in the URL. From other bug reports, it seems you're using GitHub Enterprise, not bitbucket. Up to this time, I've only heard of this problem affecting bitbucket users, and only with the user name and password embedded directly into the URL. If you resolved the issue by adding .ssh/id_rsa to the home directory of your Jenkins user, then you should also be able to use the Jenkins credentials plugin to insert that same private key into Jenkins, then reference that private key from the Git configuration within the specific job using that repository.

            Unassigned Unassigned
            flaviodonze Flavio Donzé
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: