Unable to push the code to repository
Asked by Gopi:

Hi Team,

We are trying to synchronize the repository changes from Azure repo to Bitbucket repo with same project and repo name.

Steps we followed:

1. Created a one repo in Azure by name 'sync'
2. Created a same repo in Bitbucket cloud trail version.
3. And added a mirror pipeline In yml into azure repo to trigger each commit changes to Bitbucket
4. Now we with the pipeline we are able to clone the repo from azure and trying to push but failing with below error.

![error.png](/t5/image/serverpage/image-id/281652i146DE146B663E30B/image-size/large?v=v2&px=999 "error.png")

Connections:

1. We have added the personal access token in both Azure and Bitbucket
2. We have mapped the service connections in azure to map the bitbucket repo to Azure.
3. Lastly enabled webhooks and added the repo link and given user credentials via PAT (personal access token)

Please help us to push and sync the azure repo with bitbucket repo.


Answers:
author: Theodora Boudale
body: Hi [@Gopi](/t5/user/viewprofilepage/user-id/5320617) and welcome to the community!

Based on the output, it looks like an app password is not provided in the Bitbucket repo's URL, so the process fails because it cannot give a prompt for you to enter a password.

* What type of authentication do you want to use to push to the Bitbucket repo?
  * Username and [app password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/)?
  * Or a [Repository Access token](https://support.atlassian.com/bitbucket-cloud/docs/repository-access-tokens/)?
* And what URL have you specified for the Bitbucket Cloud repo?

If you want to use username and app password, please make sure that the Bitbucket repo URL looks like this:

```
https://{bitbucket_username}:{app_password}@bitbucket.org/{workspace}/{repository}.git
```

where

**{bitbucket_username}** is the Bitbucket username of the account you generated the app password for, it can be found here <https://bitbucket.org/account/settings/> after you log in to the account  
**{app_password}** is an app password for the Bitbucket user you are authenticating with

If you want to use a repository access token, please ensure that the Bitbucket repo URL looks like this:

```
https://x-token-auth:{repository_access_token}@bitbucket.org/{workspace}/{repository}.git
```

where

**x-token-auth** is a literal string, you don't replace this with anything  
**{repository_access_token}** is the value of the repository access token

For variables like {app_password} and {repository_access_token}, we recommend storing them in secured variables, if Azure offers this option.

Please feel free to reach out if you have any questions!

Kind regards,  
Theodora

comments: author: Gopi
body: Hi Theodora,

Thank you so much for the reply, we tried both the ways , still we are faing some issues and that URL issue is still persisit.

pleas have a look on attached screenshots.

Regards,

Gopi![Screenshot.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/283644i01E425B7EEA4297C/image-size/large?v=v2&px=999 "Screenshot.JPG")![Screenshot2.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/283645iF39DF8C0E9628558/image-size/large?v=v2&px=999 "Screenshot2.JPG")


author: Theodora Boudale
body: Hi Gopi,

I see the following in the second screenshot you posted:

* You are using an email address as username. Email addresses cannot be used for authentication when you clone, pull, or push to Bitbucket repos. It needs to be the Bitbucket username, which you can find here <https://bitbucket.org/account/settings/> after you log in to the account you are authenticating with.  

* You also need to remove the curly brackets around the username and the app password. So, if the value of the username is **myusername** and the value of the app password is **ABCDEFG**, the URL needs to be

```
https://myusername:ABCDEFG@bitbucket.org/workspace/repository.git
```

I cannot see what is wrong in the first screenshot as the token is masked. However, if you enclosed the access token in curly brackets as well, this must be the culprit. You will need to remove any curly brackets from the access token.

I hope this helps, please feel free to let me know how it goes.

Kind regards,  
Theodora


author: Gopi
body: Hi Theodora,

Thank you so much for the reply, we tried both the ways , still we are faing some issues and that URL issue is still persisit again and again.

pleas have a look on attached screenshots.![Screenshot2.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/285349i9AA9F826867864ED/image-size/large?v=v2&px=999 "Screenshot2.JPG")![Screenshot.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/285350i3AB82CC381A53E88/image-size/large?v=v2&px=999 "Screenshot.JPG")


author: Theodora Boudale
body: Hi Gopi,

In the first screenshot, I see that you are still using an email for authentication in the URL, instead of a Bitbucket username, and there are also curly brackets. Please see my previous reply for an example, you will need to use a Bitbucket username instead of an email address and you also need to remove the curly brackets around the username and the app password.

For the second screenshot, the part after https://x-token-auth: in the URL is displayed as asterisks.

Are you using some variable for the access token that is masked in the log?  
If so, does the value of this variable include brackets as well? If it includes brackets or spaces, please make sure to remove the brackets or spaces from the variable value.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud