Combining Workspaces and Preserving Jira DVCS History
Asked by Steven Kling {Appfire}:

We're in process of combining several long-standing BB Cloud and 2 BBDC workspaces.

Regarding the cloud instances we have a number of questions but first a general statement: Yes, moving git repos can be done easily, even scripted via clone/push-to-new-origin but we would like to preserve the metadata: PR reviews approvals, comments. Pipeline run history, etc. And we're also interested in preserving the Jira DVCS Connector links that are mapped to branches/commits/PRs via the Developer panel on the issue screen. So...  

1. Transferring repos to new workspace - seems only possible through UI (no REST API) Doesn't seem scalable.
2. How to preserve the Jira DVCS (Issue Developer panel) links. These appear to be hashcode maps to urls in the connected DVCS acct. How can these be restored/repaired when the repo is moved from bitbucket.com/a to bitbucket.com/b?
3. There are bi-directional links established between BB and Jira instances when connected. Are these "smart" enough to re-establish links via regex patterns and commit hashes?

Thanks to anyone in advance who can shed some light here.


Answers:
author: Theodora Boudale
body: Hi Steven,

You mention you are referring to the cloud instances, so I assume we are talking about the transfer of repos between Bitbucket Cloud workspaces, and integration with Jira Cloud?

If so, I am answering your questions below:

> Transferring repos to new workspace - seems only possible through UI (no REST API) Doesn't seem scalable.

I'm afraid that there is no way to bulk transfer repos to another workspace through the UI or transfer a repo via API.

We have a feature request in our issue tracker for bulk transfer of repos from the UI:

<https://jira.atlassian.com/browse/BCLOUD-12947>

At the moment, repos will need to be transferred one by one.

> How to preserve the Jira DVCS (Issue Developer panel) links. These appear to be hashcode maps to urls in the connected DVCS acct. How can these be restored/repaired when the repo is moved from bitbucket.com/a to bitbucket.com/b?

++**Commits** , **Branches and** **Pull Requests links** in Jira Issue Development panel++

These will be preserved because the URLs are using the Repo UUID only (without the workspace UUID).

You will need to take the following actions for that:

Assume you are transferring a repo from bitbucket.org/workspace-a to bitbucket.org/workspace-b  

++If workspace-b does not have an integration with your Jira Cloud instance++ , you will simply need to integrate them and the links will work.  

++If workspace-b is already integrated with your Jira Cloud instance:++

In Jira **DVCS accounts**:

1. find **workspace-a** and select the 3 dots \> **Refresh repositories**, so that the transferred repo won't show in the list.
2. find **workspace-b** and select the 3 dots \> **Disconnect** to remove the integration. Afterwards, recreate the integration between Jira and **workspace-b** (no data will be lost if you remove and recreate the integration)

++**Pipelines links** in Jira Issue Development panel++

These links are using the workspace UUID as well (unlike Commits, Branches and Pull Requests links), so they will still point to the old workspace instead of the new one.

I will ask our development team if there is any way for these links to get updated, I'll let you know as soon as I have an update.

A few more things when transferring repos with Pipelines:

* After transferring a repo, you will need to enable Pipelines again from **Repository settings** , in order to view the builds on its **Pipelines** page, and also in order to be able to trigger new builds.
* If you are using **Deployment variables**, these will not be transferred and will need to be recreated.
* If you are making use of the Premium feature "Only allow admins to deploy to this environment", this will not work properly in the transferred repo due to a bug: <https://jira.atlassian.com/browse/BCLOUD-20918> In this case, you will need to recreate the deployment environment in question.

> There are bi-directional links established between BB and Jira instances when connected. Are these "smart" enough to re-establish links via regex patterns and commit hashes?

The links in Bitbucket Cloud repositories are also transferred. As long as there is an integration between bitbucket.org/workspace-b and your Jira Cloud instance, the Jira issue keys referenced in Bitbucket commits and PRs will remain links to the respective Jira issue.

Kind regards,  
Theodora

comments: author: Steven Kling {Appfire}
body: Thank you Theodora! This is what I needed. Perfect. Follow up if I may: Because there is no bulk transfer, is it possible to engage Atlassian Bitbucket technicians to assist in full workspace transfers?


author: Theodora Boudale
body: Hi Steven,

You are very welcome!

Regarding the Pipelines links in Jira issue development panel, I've checked with the development team and unfortunately, these links cannot be updated after repo transfer.

I have also asked about assisting you with the bulk transfer. I'm afraid that we cannot do this for security and compliance reasons, the transfer of each repo needs to be initiated and then accepted by the admins of each workspace.

Kind regards,  
Theodora


author: Steven Kling {Appfire}
body: Thanks again, Theodora! :)

Disappointing to hear on both counts but really appreciate you getting back. We'll figure something out. We've got over 1000 repos across 14 WS to consolidate. A fairly unique case I'd imagine. Guess we'll crowd-source it.


author: Steven Kling {Appfire}
body: **Update with related question:**

We're in process of merging some Jira instances as well. We have identified a handful of Jira Project Key collisions - same project key in two merging instances. This presents an issue as well with DVCS Connector and Bitbucket.  

To get issue key reference in Git commit histories and branches to continue to map and render in BB's UI after modifying the Jira Project key, we *could* modify, rewrite the entire commit history and branch names of the repository, however, this would modify the commit hash for each and break the DVCS references in Jira. We are considering doing this locally then uploading it back to a new repo entirely, thus making the old repo historical, maintaining commit hash reference from the developer panel but breaking BB's bidirectional links on the old repo. And the new repo would have bi-directional links working but only new commits going forward would then work.   

Hopefully this illustrates the problem. We're trying our best to understand how to address it and wonder if there are recommended practices.  

We're willing to sacrifice legacy pipeline references but...  

**Still hoping there may be a way with Atlassian's help we can automate the 1000+ repo transfer.**

comments: author: Theodora Boudale
body: Hi Steven,

If you rewrite history and change the commit messages to reference the new Jira issue key, the Jira issues will reference these new commits with the changed hash.

However, they will continue to reference the old commits (before history rewrite) as well, because these old commits are indexed in the Jira database.

I would suggest creating a support ticket with Jira team and ask if a resync of the repo (done by Atlassian, after you push history rewrite) can delete indexed data from the Jira database and recreate the correct links only in Jira (I don't have in-depth knowledge of Jira so I'm not sure if this is possible).

If this is possible, then a history rewrite would be a good option.

You can create a support ticket via <https://support.atlassian.com/contact/#/>, in "What can we help you with" select "Technical issues and bugs" and then select your Jira Cloud instance.

Regarding the repository transfer, there are multiple tasks running in the background when a repo is transferred, which would make a transfer done by us an error-prone process. For that reason, the transfer needs to be initiated via the UI and then accepted by an admin of the workspace you're transferring to. I'm afraid there is no way to automate this at the moment.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud

dvcs