問題描述
遠程 TFS 2015 到 Azure Devops(私有云)遷移 (Remote TFS 2015 to Azure Devops (private cloud) Migration)
我當前的組織需要將源代碼 + 歷史鏈接從位於遠程站點的供應商 TFS 2015 遷移到我們的 Azure Devops(Repos)。我面臨的挑戰是,由於源 TFS 在遠程站點中並且沒有通過我們的 AD 連接,因此找不到鏈接它的方法。目前我們正在使用顯式登錄到他們的 tfs 並獲取代碼。是否有任何可能的方法來遷移相同的內容並每天進行同步,持續幾個月並拔下對遠程的依賴。
任何幫助將不勝感激..
參考解法
方法 1:
Not sure the Azure DevOps(Repos) you mentioned are Azure DevOps Service (prior VSTS) or Azure DevOps Server 2019(prior TFS) In your case, seems you just want to perform a source code synchronization between TFS2015 to Azure DevOps service or Azure DevOps server.
For Azure DevOps Service : When you decide to make the move from Azure DevOps Server to Azure DevOps Services, there are many approaches to doing this which vary in both the fidelity of the data transfer and the complexity of the process.
- Option 1: Copy the most important assets manually
- Option 2: High fidelity database migration
- Option 3: Using public API‑based tools for higher fidelity migration
Only the option2 will include source control history during the migration. But it also have some limitation, such as import tool supported version. Currently only the following versions of Azure DevOps Server are supported for import: Azure DevOps Server 2019 and Azure DevOps Server 2019.0.1
In your scenario, you could use a CI build in TFS2015 to sync the Azure DevOps repo automatically. And the biggest challenge here is the authentication for both TFS and Azure DevOps Service. Just as you mentioned using explicit logins and powershell script should do the work.
A sample for your reference:
1. Create a CI build in TFS 2015
In your TFS 2015 project where the git repo hosted ‑> create a build definition with the TFS 2015 git repo as repository ‑> enable CI with all branches included.
2. Add a PowerShell task to sync TFS2015 git repo to Azure DevOps Service Add a PowerShell task in the build definition with below script:
if ( $(git remote) ‑contains 'vsts' )
{
git remote rm vsts 2>&1|Write‑Host
echo 'VSTS Account removed'
}
git remote add vsts https://Personal%20Access%20Token:{PAT}@{account}.visualstudio.com/{project}/_git/{repo}
git checkout ${env:BUILD_SOURCEBRANCHNAME} 2>&1|Write‑Host
git reset ‑‑hard origin/master 2>&1|Write‑Host
echo 'update local branch with remote successfully'
git push vsts ${env:BUILD_SOURCEBRANCHNAME} ‑f 2>&1|Write‑Host
Note: the vsts remote should be added with credential. And it uses PAT for authentication in the Azure DevOps Service git repo URL. And you just need to replace the real PAT, accountname, projectname and reponame in the URL https://Personal%20Access%20Token:{PAT}@marinaliu.visualstudio.com/{project}/_git/{repo}
.
Save the build definition, and now when any branches are updated in TFS 2015 git repo, VSTS git repo will be synced automatically for the corresponding branches.
(by Renji、PatrickLu‑MSFT)