19 Temmuz 2018 Perşembe

Migrate Multiple SVN Repos to GITLab

Prerequisites:
- Install gitlab to your local server (Gitlab-ce)
- Svn server access
- Personel token from Gitlab-ce user profile screen
- authors.txt file for user names in svn commits

format: svnusername = User Name

- File containing svn project names to be migrated to GitLab (projectList.txt in this script)
- Linux / Unix client to execute bash script (Curl, Git and SVN installed)
- If you want to create git projects in a group, create git group in gitlab web screen and note group id. We will need id as parameter.

What does script do?
  • Reads SVN project names one by one.
  • Creates empty project in gitlab via GitLAB api
  • Clones SVN project to local git
  • Pushes git to remote with all history and branches
Now save bash script below and execute.


# !/bin/bash
  
echo "****************************"
echo "********  Clone SVN ********"
echo "********  By: Ekrem Kucuk **"
echo "****************************" exec < projectList.txt while read line do if [ -n "$line" ] then echo Creating Git Project curl --request POST --header "PRIVATE-TOKEN: <GIT_PERSONAL_TOKEN>" "http://<GIT_URL>/api/v4/projects?name=$line&visibility=private&namespace_id=<GIT_GROUP_ID>" echo Clonning SVN Project git svn clone http://<SVN_REPO_URL>/<SVN_REPO_PATH>/$line --authors-file=/path_to/authors.txt -s $line cd $line echo Pushing to Server git remote add origin http://<GIT_USERNAME>:<GIT_PASSWORD>@<GIT_URL>/mergentech-sbs/$line.git git push -u origin --all cd .. fi done echo Clone Completed

Hiç yorum yok:

Yorum Gönder