I ran into some problems configuring ssh for my jenkins box. It turns out that when installing jenkins on ubuntu via the package manager that jenkins is setup to run as its own user. So, Jenkins did not have access to my .ssh directory. Of course this made perfect sense once I stopped and thought about it.
Anyhow, I could not find a clear answer in one place so posted here. This assumes that you have an ssh key defined for your Git service of choice. I used the same key for myself and my Jenkins user. You can of course create your own ssh key for the Jenkins User.
1. Setup the Git settings for the Jenkins account - assume the identity of the Jenkins user and configure:
sudo su jenkins
jenkins@lubuntu:~$ git config —global user.email “some email address”
jenkins@lubuntu:~$ git config —global user.name “some name you associate with jenkins”
2. cd to your user home directory and copy the .ssh key info into the Jenkins account.
sudo cp id_rsa /var/lib/jenkins/.ssh/
sudo cp id_rsa.pub /var/lib/jenkins/.ssh/
sudo jenkins:nogroup chown /var/lib/jenkins/.ssh/id_rsa
sudo jenkins:nogroup chown /var/lib/jenkins/.ssh/id_rsa.pub
3. Assume the identity of Jenkins again, cd to the Jenkins directory, create a temporary directory, clone your repository from the Git repository, fix any issues this reveals then delete the temporary directory:
sudo su jenkins
git clone git clone email@example.com:butbucket user name/user’s repository.git
rm rf junk
4. Kick off your Jenkins build and verify that the Source Code Management plugin works.