脚本方式同步gitlabA与B

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

结束。

上一篇:expect的使用


下一篇:JS可改变列宽table