1

I am using a bitbucket repository and I have a pipeline (let's call it P1) that is triggered when users commit to the repository on bitbucket. The main task done by P1 is to sync the code from the bitbucket repository with the Azure DevOps repository.

I did our first pull request directly on Azure DevOps, from a feature branch to master, and I squashed all the commits contained within the pull request. Thus my repository on Azure DevOps is now ahead of the bitbucket repository, and I need to sync them. I created a new pipeline (P2) which runs only a powershell script, and triggers it manually, as per the link.

P2 execution succeeded, but instead of the single commit coming from the pull request, only the first commit within the pull request was persisted on bitbucket. And now, triggering P2 succeeds but it tells me that the repository is up-to-date.

How can I fix this?

Also, if you have some suggestions with regards my approach, please go ahead! I could have done the pull request on bitbucket, and I think that might have avoided all this mess. And if I wouldn't have squashed the commits into a single commit as well, but it is so much cleaner...

ccoutinho
  • 3,308
  • 5
  • 39
  • 47
  • 1
    Why do you need to synchronize the two repositories? If you want to use Bitbucket for source control, then use Bitbucket. Trying to have *both* Bitbucket and Azure DevOps be a source of truth for ongoing code commits is going to be a nightmare. FWIW, Azure DevOps pipelines can consume source code from Bitbucket. – Daniel Mann Mar 19 '20 at 21:06
  • By having the code history on Azure DevOps we can link tickets to commits, and I find it makes my life easier to have it all on the same place. In addition, everything has been going smooth until we decided to start using pull requests. And I believe this is a bug that can be easily avoided in the future, but for now I just want to sync the repos again. But you are right, if this takes me too long to fix, I will follow your suggestion, and keep it simple. – ccoutinho Mar 19 '20 at 21:43

1 Answers1

1

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

ccoutinho
  • 3,308
  • 5
  • 39
  • 47
  • Please [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) once you can, this can be beneficial to other community members reading this thread. – Cece Dong - MSFT Mar 20 '20 at 03:36
  • I will, as soon as I am allowed to do so (in two days) – ccoutinho Mar 20 '20 at 04:09