A few notes on getting Jenkins-CI installed on your Mac and setup with Git and Bitbucket for source code management. I’ve been using Git for some time but I had problems / major issues with Jenkins and could never seem to get this working.
Issues with setting up Jenkins and Git on a Mac
Here are the issues I was having - the biggest issue was the Error (unable to clone) which showed up when I created a job and added the path to the Bitbucket repo - even after I had added the SSH Key to Bitbucket. It was driving me mad!
- can’t pbcopy the ssh-key from terminal for the jenkins user
- can’t run the job even though you add the ssh-key to BitBucket
- error message tells you can clone and is not helpful!
How to Install Jenkins on a Mac with Git
- Run the Jenkins-CI installer
- Go to System Admin > Users
- Create a username and password for the Jenkins user (make it an admin user too - just in case)
- Logout - Login in as Jenkins
- Go to Bitbucket.
- Go to your Account > SSH Keys
- Open Terminal on Mac
- Run ssh-keygen
- Copy your SSH Key from Terminal pbcopy < ~/.ssh/id_rsa.pub
- Paste this to Bitbucket and save.
- Go to your repo and copy it’s ssh path
- Paste this to Terminal
- Yes to add the SSH Host to your known list
- Now go to Jenkins
- Add / Edit Job
- Paste your ssh path
- Error is gone!
Note - the key point is that the SSH Host has to be added to the allowed hosts for the user jenkins - if the SSH Host (Bitbucket) is not added, then Jenkins can’t figure out how to type Yes (step 13).