linux shell脚本:通过API实现git仓库从gitee向gitlab的批量迁移(gitlab api)
生活随笔
收集整理的這篇文章主要介紹了
linux shell脚本:通过API实现git仓库从gitee向gitlab的批量迁移(gitlab api)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
gitee-url.txt.2:
git@gitee.com:proj1/javacode.git遷移腳本:
#!/bin/bash# gitlab訪(fǎng)問(wèn)憑證 PRIVATE_TOKEN="*********" # gitlab api url gitlab_api_url=https://git.zhangxueliang.com/api/v4 # gitlab test_project的namespace_id namespace_id=40 # 目標(biāo)遷移倉(cāng)庫(kù)地址 gitlab_url=https://git.zhangxueliang.com/test_project # 記住git http倉(cāng)庫(kù)賬號(hào)密碼 git config --global credential.helper cache for line in $(<gitee-url.txt.2); doline=$(echo $line | sed -e 's/\r//g');# eg:gotools.gittmp=${line#git@gitee.com:test_project/};if [[ "${line}" =~ ":xxx1" ]];thentmp=${line#git@gitee.com:xxx1/};fi# 倉(cāng)庫(kù)名稱(chēng)(不含.git) eg:gotoolsproject_name=${tmp%.git};# git clonegit clone --bare $line# 獲取namespace_id test_project=40# curl --request GET --header "PRIVATE-TOKEN:ThmpJQBf99nBYEo5N-wR" "https://git.zhangxueliang.com/api/v4/namespaces?per_page=50"# 在 gitlab 創(chuàng)建目標(biāo)倉(cāng)庫(kù)curl -k --request POST --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}" --data "name=$project_name&namespace_id=$namespace_id" $gitlab_api_url/projects# git pushcd $tmpgit push --mirror $gitlab_url/$tmpcd ..rm -fr $tmp done總結(jié)
以上是生活随笔為你收集整理的linux shell脚本:通过API实现git仓库从gitee向gitlab的批量迁移(gitlab api)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux shell if判断字符串是
- 下一篇: linux shell 判断文件是否存在