0
votes

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://[email protected]:22/DefaultCollection/_ssh/BadHombresGITSubmoduleEdition

git.exe init G:\Program Files (x86)\Jenkins\workspace\Another Test # timeout=10 Fetching upstream changes from ssh://[email protected]:22/DefaultCollection/_ssh/BadHombresGITSubmoduleEdition git.exe --version # timeout=10 using GIT_SSH to set credentials git.exe fetch --tags --progress ssh://[email protected]: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://[email protected]: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

1
Possible duplicate of how to link container in docker?cstarner

1 Answers

1
votes

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://[email protected]:22/_ssh/project
    ssh://[email protected]:22/project/_ssh/repo
    

    So you can use the URL as ssh://[email protected]: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.