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://[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?

2
  • I guess you mistyped the password. Status 401 is Unauthorized.
    – S.Spieker
    Commented Jun 11, 2014 at 6: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 - confluence.atlassian.com/display/BITBUCKET/… and this post has some info on the jenkins side of the setup: stackoverflow.com/questions/15314760/…
    – Corbell
    Commented Jun 11, 2014 at 17:55

3 Answers 3

23

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,
3
  • At last, after a few days of back and forth!
    – crafter
    Commented Feb 2, 2016 at 20:40
  • 4
    but this leaves your password in plain text. A better way is to use SSH and private key.
    – Ray
    Commented Apr 9, 2016 at 3: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. Commented Dec 27, 2017 at 21:17
7

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

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]

1
  • 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
    Commented Jun 11, 2014 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.