1

I'm trying to configure Jenkins on my Mac Mini in order to pull the code of my iPhone App from my BitBucket repository. In the "Xcode plugin" configuration area I have tried to add the git address of my project but it keeps on failing. After a research it looks like I have to use an ssh deployment key to connect Bitbucket and Jenkins. What I have done so far:

ssh-keygen -t rsa 

pbcopy <  /Users/jenkins/.ssh/id_rsa.pub

and I added this SSH key to my BitBucket profile.

Unfortunately it still doesn't work.

Can anybody explain in detail the whole process?

Claus
  • 5,662
  • 10
  • 77
  • 118
  • When you say "it doesn't work" is Jenkins giving you errors? At what point is it failing? – David Nov 07 '12 at 10:56
  • Hi David,I've used that answer for the first two steps but it doesn't work. I'm currently using the url: https://myname@bitbucket.org/myname/myproject.git – Claus Nov 07 '12 at 10:57
  • The error is: Failed to connect to repository : Error performing command: git ls-remote -h https://.... – Claus Nov 07 '12 at 10:58
  • shall I use ssh://git@bitbucket.org.... ??? – Claus Nov 07 '12 at 14:10
  • OK. I'm getting close. The error message was not clear. I've fixed the git executable directory path and now the new message is Failed to connect to repository : Command "/usr/local/git/bin/git ls-remote -h git@bitbucket.org:myname/myproject.git HEAD" 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. – Claus Nov 07 '12 at 14:24
  • I had this problem too (the documentation really doesn't go into enough detail on bitbucket) I had to recreate the ssh connection for the git user with http://stackoverflow.com/questions/10224574/jenkins-hudson-cant-connect-to-github-repo – David Nov 07 '12 at 15:22

2 Answers2

3

Ok maybe I found the solution here: http://colonelpanic.net/2011/06/jenkins-on-mac-os-x-git-w-ssh-public-key/

Remember to re-generate the keys with:

ssh-keygen -t rsa 

to copy it with:

pbcopy <  /Users/Shared/Jenkins/Home//.ssh/id_rsa.pub

to upload it in BitBucket and run:

ssh git@bitbucket.org

in order to add bitbucket among the known hosts

Claus
  • 5,662
  • 10
  • 77
  • 118
0

I think the problem is in the permission for git. In the error log the command which is failing is

/usr/local/git/bin/git clone --progress -o origin git@bitbucket.org:myname/myproject.git/Users/Shared/Jenkins/Home/jobs/MyProjectAdHocBuild/workspace

If I try to run it in the console I get this:

fatal: could not create work tree dir '/Users/Shared/Jenkins/Home/jobs/MyProjectAdHocBuild/workspace'.: Permission denied

so if I run it in SUDO mode it works.

How can I give to Jenkings the permission to run git in Admin mode?

Claus
  • 5,662
  • 10
  • 77
  • 118
  • I found a possible answer on http://stackoverflow.com/questions/12097982/jenkins-finds-cannot-find-ssh-key does anybody know how to perform these operations on the macosx console? – Claus Nov 07 '12 at 17:29