Jenkins repository errors with SSH and git

Posted: 2015-07-06 11:04:23 by Alasdair Keyes

Direct Link | RSS feed

I've been experimenting with Jenkins continuous integration (CI) suite.

CI seems to be getting widely adopted in businesses so I thought it would be good to familiarise myself with it.

I created a git repo with SSH/key pair access and created a new project in Jenkins. In the project configuration, I was able to connect to the repository with the following URL


But all my builds were failing with the following message...

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/test1/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url ssh:///git@X.X.X.X:/home/git/repo/test1.git/ # timeout=10
Fetching upstream changes from ssh:///git@X.X.X.X:/home/git/repo/test1.git/
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress ssh:///git@X.X.X.X:/home/git/repo/test1.git/ +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from ssh:///git@X.X.X.X:/home/git/repo/test1.git/
at hudson.plugins.git.GitSCM.fetchFrom(
at hudson.plugins.git.GitSCM.retrieveChanges(
at hudson.plugins.git.GitSCM.checkout(
at hudson.scm.SCM.checkout(
at hudson.model.AbstractProject.checkout(
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(
at jenkins.scm.SCMCheckoutStrategy.checkout(
at hudson.model.AbstractBuild$
at hudson.model.Run.execute(
at hudson.model.ResourceController.execute(
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress ssh:///git@X.X.X.X:/home/git/repo/test1.git/ +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stderr: ssh: Could not resolve hostname : Name or service not known
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(
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(
at hudson.plugins.git.GitSCM.fetchFrom(
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

Eventually, I noticed that the URL that was being connected during the build had an extra / in the ssh protocol definition.

It turns out that the git pluging does some escaping and ends up adding the extra /, although the Git URL is perfectly valid, it is a sloppy url as the SSH port is not explicitly defined. Change it to


And it worked with no issues and proceeded to running the build/test scripts.

If you found this useful, please feel free to donate via bitcoin to 1NT2ErDzLDBPB8CDLk6j1qUdT6FmxkMmNz

IT Consultancy Services

I'm now available for IT consultancy and software development services - Cloudee LTD.

Happy user of Digital Ocean (Affiliate link)


Validate HTML 5