26

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

The repository is private.

ghickman
  • 5,893
  • 9
  • 42
  • 51
Ian Macalinao
  • 1,608
  • 3
  • 20
  • 30

3 Answers3

40

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
ghickman
  • 5,893
  • 9
  • 42
  • 51
  • 3
    Nice, now I don't have to type my password in every time! – Ian Macalinao Nov 22 '11 at 20:28
  • 1
    Doesn't seem to work for me. Is it something else you did to make it work, or did Bitbucket change something in the mean time? Thanks! –  Jul 19 '12 at 15:40
  • 1
    @Alex this answer is nearly 3 years old so I would assume Bitbucket has changed something. Unfortunately I no longer use Bitbucket so can't check for you. – ghickman Jul 29 '14 at 10:10
  • I dont want to give my password in this URL @ghickman. And as you said. This answer seems old is there any other way to connect bitbucket repo into jenkins? – Prabhu Vignesh Rajagopal May 06 '16 at 07:45
25

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.

Steven Craft
  • 1,243
  • 11
  • 15
  • 1
    As a reminder, when doing this, to set up the SSH key as the Jenkins user, rather than your personal user, if they are different! – alttag Nov 14 '13 at 22:53
  • You should add the ssh key to the Jenkins Credentials store to make this easier to manage too – aaaarrgh Mar 01 '17 at 19:17
0

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

Abhishek K
  • 645
  • 1
  • 11
  • 23