Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Keeping Azure DevOps repo in sync with bitbucket after a pull request Edited

Hi guys!

After a pull request on Azure DevOps, from a feature branch to master, my repository on Azure DevOps is now ahead of the bitbucket repository, and I need to sync them.

Problem is, I can't. I tried running the powershell script below on an Azure Pipeline, as per the link.

if ( $(git remote) -contains 'bitbucket' ) 
{
   git remote rm bitbucket 
   echo 'remove remote bitbucket' 
} 
git remote add bitbucket https://username:password@bitbucket.org/username/repo.git
$branch="$(Build.SourceBranch)".replace("refs/heads/","") 
git checkout $branch
git push bitbucket $branch -f 

But this is failing with the following error:

fatal: unable to access '<a href="https://bitbucket.org/***/repo.git/':">https://bitbucket.org/***/repo.git/':</a>; URL using bad/illegal format or missing URL 

Any idea what I might be doing wrong? I copy pasted the script from the link, changing the username and password by the credentials I use to connect to my bitbucket account, and repo with the repository name.

 

EDIT

I was not encoding neither the username nor the password, and by changing that the pipeline is now executed until the end. However, as weird as it is, no change is being persisted on bitbucket. The powershell output is as follows:

Switched to a new branch 'master'

Branch 'master' set up to track remote branch 'master' from 'origin'. 

Everything up-to-date 

 

EDIT 2

Ok, I dug up the problem. Some data actually passed from Azure DevOps to bitbucket already: the first commit within the pull request. All other commits didn't go through.

2 answers

1 accepted

Okay, I finally managed to get this working by forcing a push in master (I can't find the exact command I used, if someone can remind me, I will update this answer).

The repository history was a little bit messed up though (explained below), but at least it is working and even though the history is not exactly in sync, the files are.


------------------------------
Azure DevOps repo history

Commit XXX

Commit AAA

Bitbucket repo history

Commit XXX

Commit YYY

Commit AAA

------------------------------


For someone using a similar configuration, I recommend making sure the pull requests are done on bitbucket, and not on Azure DevOps. This way the pipeline will always trigger after changes on the main repo, on bitbucket, and never the other way around.

I was also having a problem related with permissions, namely:

Pushes to this branch are not permitted; you must use a pull request to update this branch.

I managed to fix it by following these guidelines

I fixed this by encoding the password, following the table below: 

 

Screenshot_12.png

In fact, the pipeline runs until the end, but no change persists on bitbucket! Any idea on what might be happening? 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

485 views 5 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you