14
votes

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://[email protected]/gsmohan/quickride.git

But it gives the error below specified:

ERROR:Failed to connect to repository : Failed to connect to https://[email protected]/gsmohan/quickride.git using credentials bitbucket account (status = 401)

Can anyone please help to me?

3
I guess you mistyped the password. Status 401 is Unauthorized.S.Spieker
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 - confluence.atlassian.com/display/BITBUCKET/… and this post has some info on the jenkins side of the setup: stackoverflow.com/questions/15314760/…Corbell

3 Answers

23
votes

Change repository address to this format:

https://user:[email protected]/user/project_name.git

And of course:

  • user - your bitbucket user,
  • password- your bitbucket password,
  • project_name - name of project/repo,
7
votes

In Jenkins ver. 2.6 just use

https://[email protected]/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!!!

0
votes

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 [email protected]