1

Am trying to clone a private Bitbucket repository via a bash task in Azure DevOps. This is the command

git clone --branch master https://username:password@bitbucket.org/repo.git

Earlier I was getting this error

"fatal: could not read Password for 'https://***@bitbucket.org': terminal prompts disabled"

which is why I included the password also in the URL to get it to work, but now I get this.

fatal: unable to access 'https://bitbucket.org/realogy-abt/apipublishing.git/': Could not resolve host: ***

I have tried setting the global git configs with user.name and email, and the remote origin url, but nothing works.

git config --global user.email "xxx"
git config --global user.name "xxxx"

I'm trying this from a bash task within Azure DevOps. Any help would be appreciated. Edited to add: The same clone worked seamlessly with Github repo.

AK123
  • 365
  • 6
  • 17

1 Answers1

1

I tested it in the bash task with the below git command and it worked.

git clone https://username:password@bitbucket.org/Workspace ID/repository.git

enter image description here

enter image description here

The Username is showed in the Bitbucket profile settings .

enter image description here

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • But I do not want to import, I only want to clone it within a task to push a file to it. Our org does not want to use Azure Repos, and they want to use Bitbucket cloud only for the SCM, introducing Azure Repos just for this task would not be feasible. – AK123 Aug 23 '19 at 05:00
  • But I always get the same error. Tried it once again now. :( It always works with Github. And one point is that in the link or URL, the username just before repository.git isn't the username that I use to access the repo, it is a private repo that I have access to. Does that change anything? `Cloning into 'apipublishing'... fatal: unable to access 'https://bitbucket.org/realogy-abt/apipublishing.git/': Could not resolve host: ***` – AK123 Aug 28 '19 at 08:28
  • The repo I tested was a private repo. If it follows the command format I gave above, it should be successful.Note the username is the username showed in Bitbucket profile settings . You can also refer to this case(https://stackoverflow.com/questions/52869520/bitbucket-repo-clone-with-login-credentials) – Hugh Lin Aug 28 '19 at 09:24
  • Ok. Am not sure why I face this issue then, when it is working for others. I checked again, I have used the right username. What I was trying to say is that in the URL.. if you notice the username here is 'realogy-abt' whereas in yours it is the username. In my case it is something like this `git clone https://usename:password@bitbucket.org/realogy-abt/apipublishing.git` the username isn't the account name (realogy-abt in my case) as well, which is the case in both your example and the link provided. Not sure if that helps. – AK123 Aug 28 '19 at 09:29
  • Well, my username and Workspace ID are the same too, but for this repository that I need to access, it isn't configured that way, I mean, the Workspace ID is 'realogy-apt' that I need to clone. How do I do that? Thanks for all the help.. btw, but this is eating up a lot of brain-space now – AK123 Aug 28 '19 at 10:03
  • Does your password contain some special characters, eg:@. If the password contains special characters, it will also cause an error.Also, is your username and password in clear text in git command? – Hugh Lin Aug 30 '19 at 10:22
  • Yes. My password has special characters. Yeah.. there are currently in text in the command. – AK123 Aug 30 '19 at 11:09
  • 1
    You can try to change the password without special characters to see if it works – Hugh Lin Sep 02 '19 at 01:57
  • Thank you. That worked. On removing the special characters , it worked. – AK123 Oct 22 '19 at 12:58
  • @AK123 Glad to help you . You could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) , so it could help other community members who get the same issues and we could archive this thread, thanks.:) – Hugh Lin Oct 23 '19 at 01:10