Code Monkey home page Code Monkey logo

migratetoazurerepos's Introduction

Open in Visual Studio Code Image

Motivation

I had a task at hand to migrate all repositories from a particular team in bitbucket to Azure Repos. I knew about the UI based tool that is available to import repositories from AzureDevops but there is a limitation there. Only one repository could be moved at a time. And each time (manually) information has to be provided. If you are interested in knowing more about it please visit my article on that here.

I had to move more than three dozen bitbuket repositories and that approach did not sound exciting and hence I automated the task. Here is a link to my note

Prerequisites

Installations

Install Azure CLI from here
Install Atlassian.Bitbucket Powershell module from Powershell Administrator console.

Input Parameters

BitBucketUserName : your bitbucket user name
BitBucketEmailAlias : email id associated with bitbucket
BitBucketPassword : bitbucket password
RootFolderForProjects : local folder path for migration work. Folder does not need to exist. Folder will be deleted after the script runs successfully.
AzureDevopsPAT : AzureDevops team project PAT
$AzureDevopsOrgURL : similar to https://dev.azure.com/MyOrganizationName/
AzureDevopsTeamName : project team name in AzureDevops

Usage

-Open windows powershell as admin before you run the script
-Copy/download powershell file and execute below command

.\MigrateToAzureRepos.ps1 -BitBucketUserName "$(YourBitBucketUserName)" -BitBucketEmailAlias "$(YourBitBucketEmailID)" -BitBucketPassword "$(YourBitBucketPassword)" -RootFolderForProjects "$(LocalMachineFolderPath)" -AzureDevopsPAT "$(AzureDevopsPAT)" -AzureDevopsOrgURL "$(AzureDevopsOrgURL)" -AzureDevopsTeamName "$(YourAzureDevopsTeamName)"

Algorithm

Create local folder for clone work
Login to Bitbucket
Get a list of bitbucket teams
For each bitbucket team, get a list of projects associated with that team
-For each projects, get a list of repositories associated with that project
-For each repository,
-clone the repo to local
-check if a repository exists in Azure Repos, if not create one
-push code from local to repo in Azure Repos
continue until all repositories in particular project are migrated
continue until all projects in particular bitbucket team are migrated
continue until all teams in particular bitbucket login are migrated
Logout of bitbucket
Delete local folder
Delete AzureDevps PAT from environment

Error

If you get an error like the one below, most probably the powershell module Atlassian.Bitbucket was not installed. Install that following the steps mentioned above.

-import-module : The specified module 'Atlassian.Bitbucket' was not loaded because no valid module file was found in any module directory.
-At C:\ed\MigrateToAzureRepos\MigrateToAzureRepos.ps1:14 char:1
-+ import-module Atlassian.Bitbucket
-+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    + CategoryInfo          : ResourceUnavailable: (Atlassian.Bitbucket:String) [Import-Module], FileNotFoundException
-    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

If you get this error even after installing the module, open a new Administrator Powershell and execute the powershell file MigrateToAzureRepos.ps1 with appropriate parameters.
Apart from that if there are any issues with executing the powershell file, please let me know.

Contribution/Feedback

Please submit a pull request with as much details as possible

migratetoazurerepos's People

Contributors

kunduso avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.