0

Running Jenkins on windows machine like this -

java -jar jenkins.war --httpPort=8080

Configured a project with GIT (scm not github) as git plugin. Credential provided using is SSH username with private key. The repository url is like - ssh://username@host.domain.com:/data/repo/xyz

This git repository is on linux machine where I don't have root access. No errors while configuring project on Jenkins page. But the build failed with below error:

Git checkout, clone etc works from command line on windows machine where Jenkins is running.

ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --progress -- ssh:///user@host.domain.com:/data/sde-repo/SOA +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host  port 22: Connection refused
fatal: Could not read from remote repository.

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

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2174)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1866)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:547)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:760)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1152)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
    at hudson.scm.SCM.checkout(SCM.java:504)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
    at hudson.model.Run.execute(Run.java:1815)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE

To me it looks like somehow Jenkins is not able to recognize the hostname because hostname is empty in this error -

ssh: connect to host port 22: Connection refused

Is that the case? or am I going in wrong direction?

James Z
  • 12,209
  • 10
  • 24
  • 44
Viv
  • 1
  • 2
  • Possible duplicate of [fatal: Could not read from remote repository.error in using jenkins](https://stackoverflow.com/questions/22008186/fatal-could-not-read-from-remote-repository-error-in-using-jenkins) – Kavitha Karunakaran Oct 10 '19 at 13:58
  • Your questions says `ssh://...` but the error says `ssh:///`. Is there an extra slash? – James Z Oct 10 '19 at 15:46
  • I checked. There is no extra slash in the configuration. – Viv Oct 11 '19 at 05:17

1 Answers1

0

I tried a few things from @James Z comment like removing one /, adding / at the end etc. But it worked by adding double quotes in GIT repository url under "Source Code Management" section on Jenkins page like this -

"ssh://user@host.domain.com:/data/sde-repo/somefolder"

I'm not sure though why it requires a double-quoted URL.

Viv
  • 1
  • 2