0

When first attempting to check out my vsts git repo jenkins fails, however if I don't delete the workspace and run the jenkins build again it succeeds.

I've checked my credentials in settings and they haven't changed, Jenkins doesn't complain about not being able to access the repo from there.

If I do a clone in console separately it works fine.

This is the output I'm getting now:

Building in workspace G:\Program Files (x86)\Jenkins\workspace\Another Test Cloning the remote Git repository Cloning repository ssh://kintsugi@vs-ssh.visualstudio.com:22/DefaultCollection/_ssh/BadHombresGITSubmoduleEdition

git.exe init G:\Program Files (x86)\Jenkins\workspace\Another Test # timeout=10 Fetching upstream changes from ssh://kintsugi@vs-ssh.visualstudio.com:22/DefaultCollection/_ssh/BadHombresGITSubmoduleEdition git.exe --version # timeout=10 using GIT_SSH to set credentials git.exe fetch --tags --progress ssh://kintsugi@vs-ssh.visualstudio.com:22/DefaultCollection/_ssh/BadHombresGITSubmoduleEdition +refs/heads/:refs/remotes/origin/ ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress ssh://kintsugi@vs-ssh.visualstudio.com:22/DefaultCollection/_ssh/BadHombresGITSubmoduleEdition +refs/heads/:refs/remotes/origin/" returned status code 128: stdout: stderr: System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 65.52.8.37:22 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at Microsoft.TeamFoundation.Ssh.Server.External.Eldos.EldosSshCommandClient.ClientSocket_OnOpenConnection(IAsyncResult asyncResult) in D:\v2.0\A1_work\14\s\Tfs\Service\Ssh\External\Eldos\EldosSshCommandClient.cs:line 332fatal: 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:1970) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1689) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:380) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:589) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1083) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1123) at hudson.scm.SCM.checkout(SCM.java:495) at hudson.model.AbstractProject.checkout(AbstractProject.java:1212) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:566) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:491) at hudson.model.Run.execute(Run.java:1737) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421) ERROR: Error cloning remote repo 'origin' Finished: FAILURE

meds
  • 21,699
  • 37
  • 163
  • 314
  • Possible duplicate of [how to link container in docker?](https://stackoverflow.com/questions/41768157/how-to-link-container-in-docker) – cstarner Nov 08 '17 at 21:54

1 Answers1

1

Please trouble shooting the issue with below aspects:

1. Check if the SSH key is added in VSTS

For the local machine which you setup the jenkins server, you should add the SSH to VSTS account:

  • Generate SSH key for the local machine by ssh-keygen.
  • Add the public key (the content of id_rsa.pub) to your VSTS account.

2. Check the configure of your jenkins job

  • URL

    In the Source Code Management, input the URL with SSH URL with the format like:

    ssh://account@vs-ssh.visualstudio.com:22/_ssh/project
    ssh://account@vs-ssh.visualstudio.com:22/project/_ssh/repo
    

    So you can use the URL as ssh://kintsugi@vsssh.visualstudio.com:22/_ssh/BadHombresGITSubmoduleEdition.

  • Credentials

    Do not add any credentials since the local machine already has the SSH key.

  • Branches

    Specify the branch(es) to build, you can specify a certain branch name or leave it blank for building all branches.

    enter image description here

Then the VSTS git repo should be cloned successful by SSH in Jenkins job.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • so it would sometimes pull and sometimes not, looked random. I realized I had set the credentials to a value I had specified (ssh with username) but as you point out you don't need it set if the machine already has the appropriate ssh keypair, setting it to 'none' fixed the issue and now checkouts work every time, thanks! :D – meds Nov 09 '17 at 07:46