码迷,mamicode.com
首页 > 其他好文 > 详细

脚本方式同步gitlabA与B

时间:2020-05-28 21:55:57      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:span   lin   push   echo   git pull   while   null   origin   apple   

sh脚本下载gitlab-A的代码,

exp脚本自动读入gitlab-B的用户名及密码,提交实现同步.

$ cat ai_sdk_middleware.sh 

#!/bin/bash

cd /opt/gitlabmirror-repo/Faceline

git clone ssh://git@gitlab.xxxxxx.com:9022/faceline/ai_sdk_middleware.git

cp ai_sdk_middleware.exp ai_sdk_middleware/

git branch -r | grep -v ‘\->‘ | while read remote; do git branch --track "${remote#origin/}" "$remote"; done

git fetch --all

git pull --all

cd ai_sdk_middleware

git fetch --all

git pull --all

echo ‘*.exp‘ >> .git/info/exclude

$ cat ai_sdk_middleware.exp

#!/usr/bin/expect -f

set user "root"

set pwd "1qaz1qaz"

spawn git remote rename origin old-origin

spawn git remote add origin http://172.16.2.42:8099/faceline/ai_sdk_middleware

spawn git push -u origin --all 

    expect "Username*"

    send "$user\r"

    expect "Password*"

    send "$pwd\r"

    expect eof

spawn git push origin  --tags --force 

    expect "Username*"

    send "$user\r"

    expect "Password*"

    send "$pwd\r"

    expect eof

定时同步:

* 6 * * * /opt/gitlabmirror-repo/Faceline/ai_sdk_middleware.sh && cd /opt/gitlabmirror-repo/Faceline/ai_sdk_middleware && /usr/bin/expect -f ai_sdk_middleware.exp >/dev/null 2>&1

结束。

脚本方式同步gitlabA与B

标签:span   lin   push   echo   git pull   while   null   origin   apple   

原文地址:https://www.cnblogs.com/liusingbon/p/12983813.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!