Using Jenkins with a private BitBucket Git repository Using Jenkins with a private BitBucket Git repository jenkins jenkins

Using Jenkins with a private BitBucket Git repository


I'm not familiar with Jenkins but Bitbucket allows you to clone git repositories over https which can accept the password as part of the url, like so:

https://<user>:<pass>@bitbucket.org/<user>/<project>.git


For this purpose I switched over to using the SSH protocol to talk to BitBucket. By doing this I was able to set up a private/public key pair, with the private key on my Jenkins build machine, and the public key added to my account on BitBucket. SSH can then be set up to authenticate based on this key pair.

A word of warning, if your Jenkins machine is windows based, I'd avoid using plink/TortoisePLink as the SSH agent, and instead use OpenSSH from Cygwin as it is a lot faster when cloning/updating large repositories. It was a little tricky to set this up at first, but would probably warrant a separate Stack Overflow question if required.


Please make sure GIT is installed and path is configured in Jenkins. To configure path have a look at the link Jenkins could not run git

I am able to connect private repository using credentials in Jenkins. To connect using ssh please follow the youtube link Private repositories, GitHub & BitBucket