2

My Git version is 1.8.0, for this version, the Git installation path in Jenkins is C:\Git\cmd\git.exe (in older versions, it is C:\Git\cmd\git.cmd). This solves the problem that I had: error deleting workspace. In Jenkins, Git repository URL uses the ssh protocol: git@github.com:xxxxx/xxx.git, for me, this URL works. If your key can't be found, this URL will return an error, you need to define %HOME%, then your key should be in %HOME%.ssh. then I started to build. When I built it, I got:

 stdout: Cloning into 'C:\Jenkins\workspace\Lily'...

 stderr: Permission denied (publickey).
 fatal: Could not read from remote repository.

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

at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:897)
at hudson.plugins.git.GitAPI.access$000(GitAPI.java:42)

I don't understand why Jenkins can find my key for the repository URL, but can't find my key when it clones the repository.

Any help will be greatly appreciated.

Lily Ju
  • 31
  • 1
  • 4
  • possible duplicate of [Jenkins - Git - Permission denied (publickey)](http://stackoverflow.com/questions/6515039/jenkins-git-permission-denied-publickey) – Mark O'Connor Jan 20 '13 at 21:26
  • Thank you for your reply, Mark. Yes, I read the link you put here, but that link says using the same command in CMD does not work either and the auther put the key to the remote server and it was solved. My case is that my git command does work in CMD, and I do have a key in my Github, otherwise, I would not have been able to use CMD to interact with Github. – Lily Ju Jan 20 '13 at 21:56
  • Have you tried setting the HOME environment variable as suggested? Reportedly the problem is an inability to find the private key (Located by default: %HOME%\.ssh\id_rsa). Finally I normally run all these tools on Linux systems, it's a lot easier if switching OS is an option. – Mark O'Connor Jan 20 '13 at 22:07
  • 1
    Mark, thank you. After I copied G:/.ssh/id_rsa to %HOME%/.ssh/, But when I tried to build it, I got: Started by user anonymous Building in workspace C:\Program Files\Jenkins\jobs\CAREBuild\workspace ... ERROR: Failed to clean the workspace java.io.IOException: Unable to delete C:\Program Files\Jenkins\jobs\CAREBuild\workspace ERROR: Error cloning remote repo 'origin' : Failed to delete workspace ) ERROR: Could not clone repository... I am not a Linux expert, if you have detailed step byt step instructions, I'd like to try. – Lily Ju Jan 21 '13 at 13:58
  • Sounds like you've moved onto the next problem.... If a user process has a file handle open to a file within the workspace, Jenkins will be prevented from deleting that directory.... It's a windows "feature" that can be incredibly annoying in my experience..... – Mark O'Connor Jan 21 '13 at 15:25
  • I restarted my Windows to make sure no other processes are opening a file within the workspace. Every time, when I build, it will have this error message. Now I am thinking the error: Could not clone repository might be the root cause. I have no clue why I can't clone the repository or no clue why Jenkins creates the workspace and tries to delete it but it can't. Mark, do you have any clue? – Lily Ju Jan 21 '13 at 19:12
  • Apologies, not a windows guy. – Mark O'Connor Jan 21 '13 at 19:22
  • This might be just a Jenkins problem. I did not spawn a child process to build my project, why am I getting this: Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information ERROR: Failed to clean the workspace Thank you so much again. – Lily Ju Jan 21 '13 at 20:11

1 Answers1

1

My company has a proxy server, for me, to use SSH protocol is very difficult, it may have a way to solve the combination of a proxy server and ssh-to-github, but I gave up. In stead, I used https protocol. In order not to prompt credentials for Jenkins, I used github credential cache to solve this. Check here for credential cache: http://www.kernel.org/pub/software/scm/git/docs/git-credential-cache.html. Now my Jenkins/Git build works in Windows.

Lily Ju
  • 31
  • 1
  • 4