This migrates BitBucket repositories to Azure DevOps. It will clone the repo from bitbucket, modify the remote origin, and push it to Azure DevOps, therefore preserving all commit history and branches.
It will not migrate Git LFS.
- curl
sudo apt-get -y install curl - jq
sudo apt-get -y install jq - Your git client must authenticate to BitBucket and Azure Devops using SSH
Fill in the variables...
BB_ORG: The value here from this URL: https://bitbucket.org/${BB_ORG}BB_USER: Username from this pageBB_TOKEN: App Password, make one here. Give it read permission for repositories.ADO_ORG: The Azure DevOps organiztion, URL is something like https://dev.azure.com/${ADO_ORG}ADO_PAT: Personal Access Token, make one here: https://dev.azure.com/${ADO_ORG}/_usersSettings/tokens. Give it full repository permission.
bash get-repos.sh
This will generate a repos.csv file containing a list of all the repository names associated with your ${BB_ORG}
The repos.csv file will map bitbucket sources to Azure Devops projects. Column two must be the Azure Devops project name, which will be the parent for this repository.
The destination project must already exist in Azure Devops before running the next script.
The destination repository must NOT already exist in Azure Devops; It will be created during execution.
If you don't want to bring a repository over, you can just remove it's row from the CSV file.
See the sample below if you want to.
Once you've created the mapping, run the script
bash migrate-repos.sh
This will create the repository using Azure Devops REST API, and push the repo to Azure Devops
If you somehow didn't get your mapping quite right, or otherwise some catastrophe happened, you can clear repos from the Azure DevOps org with the below script.
The script will delete all repos as mapped in repos.csv. You can reduce repos.csv before running this to limit the blast radius of the deletion.
The script requires an additional flag --delete to actually delete the repos. Otherwise, it will simply list the repos it's about to delete.
bash delete-repos-devops.sh
You can check out the repos.sample.csv for an example of what the final mapping file should look like
You can see what I cloned from BitBucket to AzureDevops
For migrating JIRA Tickets, this worked for me
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request