Gitlab+Gerrit集成

集成方式:

从Gitlab上PULL代码
PUSH代码到Gerrit上
Gerrit代码合并后,同步到Gitlab上
(我还用了Jenkins,不过算不上集成,只是从Gitlab上获取代码罢了)

环境

gerrit-3.2.3.war(如果有时间的话,我会再写一章部署Gerrit的)
git version 2.12.2

1.配置GitLab,Gerrit免密

GitLab:

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.19.215

Gerrit:

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.19.207

2.创建gitlab的private项目

3.创建gerrit的同名项目

4.将公钥复制到gitlab中root账号的ssh_keys中

5.将公钥复制到Gerrit中sshkeys中

6.删除Gerrit服务器中git仓库中刚创建的git目录

参考:

rm -rf /root/gerrit/git/test.git/

7.然后把gitlab的项目克隆到Gerrit的目录中

cd /root/gerrit/git
git clone --bare git@192.168.19.207:ops_group/test.git

8.添加Gerrit配置:

vim gerrit.config

[plugins]
      allowRemoteAdmin = true

9.重启gerrit

  bin/gerrit.sh restart

10.配置replication插件
vim etc/replication.config

[remote "cku-oa"]
projects = cku-oa
url = git@192.168.19.207:ops_group/test.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
push = +refs/changes/*:refs/changes/*
threads = 3

12.不重启Gerrit重新加载replication

ssh -p 29418 admin@192.168.19.215 gerrit plugin reload replication

参考:

https://www.cnblogs.com/anliven/p/12019974.html

客户端pull代码

git clone "ssh://admin@192.168.19.215:29418/test" && scp -p -P 29418 admin@192.168.19.215:hooks/commit-msg "test/.git/hooks/"

客户端push代码

git push -u origin HEAD:refs/for/master
0 0 votes
文章评分
订阅
提醒
guest
0 评论
最旧
最新 得票最多