1
votes

I'm setting up Jenkins with GitHub. Following is what I have done so far:

  1. Installed Jenkins and Git on one of our Windows VM's.
  2. Received a common user. I am using this user for github.
  3. Setup ssh keys with this user and added these ssh keys to github account.
  4. Copied Git SSH keys to Jenkins folder also.

After all above when I try to run the job [the job just pull a repo], I'm getting the following error:

Building in workspace D:\Jenkins\workspace\test C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository C:\Program Files\Git\bin\git.exe config remote.origin.url [email protected]:ABC/REPO.git # timeout=10 Fetching upstream changes from [email protected]:ABC/REPO.git C:\Program Files\Git\bin\git.exe --version # timeout=10 using GIT_ASKPASS to set credentials C:\Program Files\Git\bin\git.exe fetch --tags --force --progress [email protected]:ABC/REPO.git +refs/heads/:refs/remotes/origin/ ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from [email protected]:ABC/REPO.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186) 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:1810) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Caused by: hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --force --progress [email protected]:ABC/REPO.git +refs/heads/:refs/remotes/origin/" returned status code 128: stdout: stderr: Host key verification failed. 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:2042) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442) at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886) ... 11 more ERROR: Error fetching remote repo 'origin' Finished: FAILURE

1

1 Answers

1
votes

Make sure to use the Jenkins SSH credentials in order to record the private key with that plugin.

Then you can use that credential for your job.

In the OP's case, there were two issues:

  • private key generate with 4096 bits (instead of the default 1024)
  • private key generate with the new OPENSSL format (instead of the legacy OpenSSH one), as explained here.
  • make sure the private key is registered in the global scope (as a global credential):

global scope