I'm very new to git and also Jenkins.
I added the ssh
keys to the bitbucket and in my local machine, when I do :
git clone git@bitbucket.org:username/repo.git
I can be able to clone.
But when I add the same url (git@bitbucket.org:username/repo.git
) to the Jenkins repository url I get an following error:
Failed to connect to repository : Command "git ls-remote -h git@bitbucket.org:username/repo.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
You need to set up the ssh keys for the Jenkins user too.
The general idea is that you log into the Jenkins box, and become the "jenkins" user. You could have called your Jenkins user anything, so make sure to use the right name. Once you're the Jenkins user, you can use
ssh-keygen
to create a new set of ssh keys. Then you can add them to your repo as deployment keys.This might be useful too: Configuring Jenkins with Bitbucket