Bug 423066 - Impossible to enter correct ssh schema repository URL
Summary: Impossible to enter correct ssh schema repository URL
Status: NEW
Alias: None
Product: Hudson
Classification: Technology
Component: GIT (show other bugs)
Version: 3.1.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Winston Prakash CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-03 11:49 EST by Alex Pogrebnyak CLA
Modified: 2013-12-03 16:19 EST (History)
0 users

See Also:


Attachments
Test for dubious use of URIish.toPrivateString (628 bytes, application/octet-stream)
2013-12-03 16:02 EST, Alex Pogrebnyak CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Pogrebnyak CLA 2013-12-03 11:49:12 EST
I enter the following URI for my git repository:

ssh://git@bitbucket.org:my-account/my-repo.git

When I save project and view URL of repository it appears to have triple slash for schema, i.e.

ssh:///git@bitbucket.org:my-account/my-repo.git

It later fails to clone the repo with the following stack trace:

ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException: Could not clone ssh:///git@bitbucket.org:my-account/my-repo.git
	at hudson.plugins.git.GitAPI.clone(GitAPI.java:244)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1016)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:963)
	at hudson.FilePath.act(FilePath.java:793)
	at hudson.FilePath.act(FilePath.java:775)
	at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:963)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:742)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1523)
	at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:610)
	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:517)
	at hudson.model.Run.run(Run.java:1434)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:82)
	at hudson.model.Executor.run(Executor.java:137)
Caused by: hudson.plugins.git.GitException: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
	at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:237)
	at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:224)
	at hudson.FilePath.act(FilePath.java:793)
	at hudson.FilePath.act(FilePath.java:775)
	at hudson.plugins.git.GitAPI.clone(GitAPI.java:224)
	... 13 more
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of fetch command
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:143)
	at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:179)
	at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
	at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:231)
	... 17 more
Caused by: org.eclipse.jgit.errors.NotSupportedException: URI not supported: ssh:///git@bitbucket.org:my-account/my-repo.git
	at org.eclipse.jgit.transport.Transport.open(Transport.java:556)
	at org.eclipse.jgit.transport.Transport.open(Transport.java:430)
	at org.eclipse.jgit.transport.Transport.open(Transport.java:314)
	at org.eclipse.jgit.transport.Transport.open(Transport.java:284)
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:118)
	... 20 more
Trying next repository
FATAL: Could not clone repository
hudson.plugins.git.GitException: Could not clone repository
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:1027)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:963)
	at hudson.FilePath.act(FilePath.java:793)
	at hudson.FilePath.act(FilePath.java:775)
	at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:963)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:742)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1523)
	at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:610)
	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:517)
	at hudson.model.Run.run(Run.java:1434)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:82)
	at hudson.model.Executor.run(Executor.java:137)

It kind of works if I leave the ssh:// schema prefix out, but my repo has submodules and it fails later on, when parsing the .gitmodules file.  I am going to write up the bug on this shortly
Comment 1 Alex Pogrebnyak CLA 2013-12-03 12:02:11 EST
I've created Bug 423068 that describes why I cannot leave 'ssh://' prefix out.
Comment 2 Alex Pogrebnyak CLA 2013-12-03 12:29:11 EST
I checked the job's config.xml, and nowhere in the config there is a full URL path.

Here is the relevant section:

          <remoteRepositories>
            <RemoteConfig>
              <name>origin</name>
              <uris>
                <org.eclipse.jgit.transport.URIish>
                  <scheme>ssh</scheme>
                  <path>git@bitbucket.org:my-account/my-repo.git</path>
                  <rawPath>git@bitbucket.org:my-account/my-repo.git</rawPath>
                  <port>-1</port>
                </org.eclipse.jgit.transport.URIish>
              </uris>

So, I guess, the problem is somewhere in the URL constructor, that parses this metadata and inserts extra slash(/)
Comment 3 Alex Pogrebnyak CLA 2013-12-03 16:02:24 EST
Created attachment 237978 [details]
Test for dubious use of URIish.toPrivateString

In this test URIish is constructed from the same parts found in the job's config.xml.

As you can see call to 'toPrivateString' results in a triple slash.
Comment 4 Alex Pogrebnyak CLA 2013-12-03 16:19:13 EST
Figured out that URL was not correct.

ssh bitbucket URL should be:

ssh://bitbucket.org/my-account/my-project.git

This way URI is serialized into this XML

              <uris>
                <org.eclipse.jgit.transport.URIish>
                  <scheme>ssh</scheme>
                  <path>/my-account/my-project.git</path>
                  <rawPath>/my-account/my-project.git</rawPath>
                  <user>git</user>
                  <port>-1</port>
                  <host>bitbucket.org</host>
                </org.eclipse.jgit.transport.URIish>
              </uris>

I think there is still an issue in that the plugin should provide validation for SSH URL conformance.