置Gerrit到Gitlab的自动同步

热度 33

说明:配置Gerrit的replication插件,把库文件自动同步到Gitlab。在安装gerrit是需要开启replication插件功能。


服务器注明
Gerrit 192.168.1.10     安装目录 /home/gerrit/
Gitlab 192.168.1.12

1. 在gerrit上生成密钥 (root用户登入)
ssh-keygen -t rsa -C "gerrit@gerrit.com" #邮箱随意设置
当前用户的.ssh目录下会生成id_rsa,id_rsa.pub,复制id_rsa.pub的内容,添加到Gitlab管理员root账号的sshkey中。

2. 把gitlab服务器添加到“已知主机”,输入指令并生成 ~/.ssh/known_hosts文件
ssh-keyscan -t rsa 192.168.1.12 >> ~/.ssh/known_hosts

3. 创建文件 ~/.ssh/config,并输入如下内容
Host 192.168.1.12
IdentityFile ~/.ssh/id_rsa
PreferredAuthentications publickey


4. 创建文件/home/gerrit/etc/replication.config,并输入如下内容
[remote "gitlab"]
url = git@192.168.1.12:root/${name}.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
push = +refs/changes/*:refs/changes/*
threads = 3

5. 重启gerrit
/home/gerrit/bin/gerrit.sh restart

在gerrit上创建库,然后把源码等文件push到gerrit库,会自动同步到gitlab上


服务热线

020-28186508

加微信咨询