Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jenkins with a private BitBucket Git repository

When setting up a project in Jenkins that's hosted on bitbucket what would I put in the URL field?

The repository is private.

like image 945
Ian Macalinao Avatar asked Nov 21 '11 06:11

Ian Macalinao


People also ask

How do I make my Bitbucket repository private?

Set repository privacy statusFrom the repository, click Repository settings in the sidebar. Locate Access level on the Repository details page. Add or remove the checkmark from This is a private repository based on your preferred privacy status. Click Save repository details.


2 Answers

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 
like image 93
ghickman Avatar answered Oct 05 '22 16:10

ghickman


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.

like image 21
Steven Craft Avatar answered Oct 05 '22 15:10

Steven Craft