15

I am using jenkins and trying to connect to the bit bucket remote repository for that I provide the bit bucket URL in source code management in git repositories, I create the credentials also for that bit bucket account added in the credentials

I tried the below in git repositories

https://nagarjun123@bitbucket.org/gsmohan/quickride.git

But it gives the error below specified:

ERROR:Failed to connect to repository : Failed to connect to https://nagarjun123@bitbucket.org/gsmohan/quickride.git using credentials bitbucket account (status = 401)

Can anyone please help to me?

reto
  • 9,995
  • 5
  • 53
  • 52
user3619128
  • 285
  • 1
  • 5
  • 12
  • I guess you mistyped the password. Status 401 is Unauthorized. – S.Spieker Jun 11 '14 at 06:31
  • I have used both https and ssh authentication in Jenkins w/Bitbucket and never needed to encode the password in the URL. Double-checking the password in your credentials is a good idea; otherwise the best bet is to generate ssh keys and use them for your authentication (using the ssh form of the URL). Atlassian has complete help on ssh setup - https://confluence.atlassian.com/display/BITBUCKET/Use+the+SSH+protocol+with+Bitbucket and this post has some info on the jenkins side of the setup: http://stackoverflow.com/questions/15314760/managing-ssh-keys-within-jenkins-for-git – Corbell Jun 11 '14 at 17:55

3 Answers3

23

Change repository address to this format:

https://user:password@bitbucket.org/user/project_name.git

And of course:

  • user - your bitbucket user,
  • password- your bitbucket password,
  • project_name - name of project/repo,
tostao
  • 2,803
  • 4
  • 38
  • 61
  • At last, after a few days of back and forth! – crafter Feb 02 '16 at 20:40
  • 4
    but this leaves your password in plain text. A better way is to use SSH and private key. – Ray Apr 09 '16 at 03:13
  • 2
    Before going this route, just make sure you aren't a dumby, and check if git is installed on your server. I had made the mistake, and thought git was already installed on the server...it wasn't. – Dan Zuzevich Dec 27 '17 at 21:17
7

In Jenkins ver. 2.6 just use

https://user@bitbucket.org/user/project_name.git 

And add your credentials.

enter image description here Important: Make sure that your git installed version is greater or equals than 1.7.4 because of the --local issue.

If you are on CentOS maybe you face the same problem than me. Here is a great answer from @AmirHd to upgrade git version on CentOS, if you already have git installed just type:

yum --disablerepo=base,updates --enablerepo=rpmforge-extras update git

Hope this helps!!!

Community
  • 1
  • 1
Gueorgui Obregon
  • 5,077
  • 3
  • 33
  • 57
0

I personnaly use that structure :

git@CREDENTIALS:BUCKET_TEAM/BUCKET_REPO.git

Questions : How many credentials do you have ? If you have more than one, you should clearly setup them within your server

Be carefull ! Jenkins when adding SSh keys DOES NOT accept passphrases

check your ssh keys within $HOME/.ssh/config and $HOME/.ssh/know_host of jenkins user (if jenkins is a service) or your application server user

One last point, YOU MUST first login with your jenkins user using SSH before enabling jenkins sync with git with a ssh git@bitbucket.org

aorfevre
  • 5,034
  • 3
  • 21
  • 51
  • Hey guys, thank you in advance for telling me what is incorrect in my reply. I have faced lots of issue concerning JENKINS specially with authentication of multiple CREDENTIALS. – aorfevre Jun 11 '14 at 21:21