/
90. Bitbucket migration automation script

90. Bitbucket migration automation script

Aim: To build a script which can help in automating the process of Bitbucket server to cloud migration

Current Scenario:

  • Clone the repository that is present in the Bitbucket server to the local

  • Execute related git commands and remove the remote origin

  • Push the cloned repository to the cloud

The above process must be followed for all the repositories that are present in the Bitbucket server one by one.

Currently followed steps for migration: (for each repository one by one)

  • Step 1: Clone repository from Bitbucket server

    • git clone “Bitbucket server repository remote URL“

  • Step 2: Fetch all remote branches from the Bitbucket server & pull latest data for all the branches

    • for remote in git branch -r; do git branch --track ${remote#origin/} $remote; done

    • git fetch --all

    • git pull --all

  • Step 3: remove the remote link(Bitbucket server link) for the clones repository.

    • git remote rm origin

  • Step 4: Add Bitbucket cloud remote link (copy from the repository page) & push all the repo data to cloud Bitbucket

    • git remote add origin "Bitbucket cloud repository remote URL"

  • Step 5:

    • git push --all

Requirement:

The script that will be implemented must carry out the following tasks:

  • Step 1: Read the list of Bitbucket server repository names one by one present in the csv file and get the remote URLs of each of them

  • Step 2: Using the same repository names fetch the remote URLs from cloud instance

  • Step 3: Execute the above mentioned git commands for each repository by using remote URLs in commands as and when

Sample csv data:

Server Repository Name

Server remote URL (fetch this)

Cloud Repository Name

Cloud remote URL (fetch this)

Server Repository Name

Server remote URL (fetch this)

Cloud Repository Name

Cloud remote URL (fetch this)

jira-bud-app01

https://bitbucketserver.com/jira-bud-app01.git

jira-bud-app01

https://bitbucketcloud.com/jira-bud-app01.git

jira-eup-app01

https://bitbucketserver.com/jira-eup-app01.git

jira-eup-app01

https://bitbucketcloud.com/jira-eup-app01.git

Ultimately, the script must be able to carry out all the tasks that are manual for Bitbucket migration.

Estimation:

Tasks

Description

Estimated Hours

Tasks

Description

Estimated Hours

1

https://empyrajira.atlassian.net/browse/AP-1620

Bit-bucket server to cloud migration

14h

2

https://empyrajira.atlassian.net/browse/AP-1621

 

20h

3

https://empyrajira.atlassian.net/browse/AP-1622

 

20h

4

https://empyrajira.atlassian.net/browse/AP-1623

 

8h

5

 

Total

62h