Gerrit - Gerrit与GitLab集成
1 - 简介
虽然Gerrit 本身提供 Code Review和 Git 仓库的两大功能,但实际上很多项目用的是其他的Git仓库,例如GitLab和GitHub。
一般情况下,Gerrit位于最终代码库的前面一层,用于代码的人工审核和对CI任务的触发进行验证。
这里以GitLab为例
Gerrit和GitLab集成后,在Gerrit上的项目仓库有变化时,会自动同步到GitLab上对应的项目仓库中。
但Gerrit和GitLab的同步只能是单向同步(Gerrit--》GitLab),也就是说直接在GitLab上项目仓库的变动不会自动同步到Gerrit上。
因此建议在Gerrit和GitLab集成后,所有的操作都在Gerrit上完成。
Replication插件
如果想要将Gerrit上的改动自动同步到GitLab上,就需要用到Gerrit的Replication插件。
Replication 插件可以同时对接已有的 Git 仓库系统,通常用于提供 changes 的镜像或者热备份,自动地将 Gerrit Code Review创建的任何改动 push 到另外一个系统里。
2 - 权限配置
2.1 配置Gerrit访问GitLab
将Gerrit的公钥添加到GitLab的管理员账号后,Gerrit服务可以通过SSH拉取GitLab上任意项目的代码。
特别注意:gerrit用户和root用户的公钥都要添加!
[gerrit@mt101 ~]$ pwd
/home/gerrit
[gerrit@mt101 ~]$ whoami
gerrit
[gerrit@mt101 ~]$ pwd
/home/gerrit
[gerrit@mt101 ~]$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCE36kKv9cRTR/UU+7c620a6sYwptzVCRa8KBWBVijXNME+te4Nt2ZKp1uVvVOYKWv4akR/E5wMMTa9sYiE7EZJsC0cfg+FSuvc7WeoyT0hWYEWAabqp1cAApZUKSm7c06829dSTAPLj4MIEQOtEzID8iaq7+kGDf6RsGF6QRrAVx28k5ZJNvNFLpFqv4cjOaDbWOKaVXkrAgYYdLWWJ6xEeQTJ6yxCkk9KY7+rHEHd9zEoJYiA03J9UgxRRkyTX8vRW39RHVVM+GriOasAgwhvhFZXJsm6mJVXr2Y3AFcMNPo4YJNq68LGdU8bjqN78ysBbkxfIDq+r3ANc7+D+Az sshtest
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ su - root
Password:
Last login: Fri Dec 13 23:15:07 CST 2019 on pts/0
ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1576224692
[root@mt101 ~]#
[root@mt101 ~]# pwd
/root
[root@mt101 ~]# whoami
root
[root@mt101 ~]# ll .ssh
total 8
-rw------- 1 root root 1679 Dec 11 23:10 id_rsa
-rw-r--r-- 1 root root 392 Dec 11 23:10 id_rsa.pub
[root@mt101 ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkUOVXJ49OolxX34Lh/qlLmdEtYbPWlELx/Kxk6EWfmuGI6eYYVIOSE4b43nEXP0T0DM8j0jat75dZ4Zc+Z21PVplJ4uUuruBV/JMfOzx2vUD2zAFELq0TX4IMRJpPjYrk6asx1KYQUr/lQIxgqUbFsTDFWmIM186kcl4Q2daU8hznfP7pJBu4DAowxVPP+OsnhT93jq8IIwUFnaUBDUh5Fr/T56b0hOljUWFAIImB5j+SsYg5airaJK44AhuoeOnrUAQEApsdqOtRdyFdwpYgQVvN61WQKJlBOwmV8lGGUZeuvYmPeSf0VzUUPmhGIgtwyeTrr7I1TcpncffAILy/ root@mt101
[root@mt101 ~]#
[root@mt101 ~]# exit
logout
[gerrit@mt101 ~]$
root账户登录GitLab:Settings---》SSH Keys---》添加并保存。
2.2 配置GitLab访问Gerrit
GitLab:192.168.16.102
[root@mt102 ~]# pwd
/root
[root@mt102 ~]# whoami
root
[root@mt102 ~]# ll .ssh
total 8
-rw------- 1 root root 1679 Dec 11 15:37 id_rsa
-rw-r--r-- 1 root root 392 Dec 11 15:37 id_rsa.pub
[root@mt102 ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGiLcDnAaj2gOemJKcnlGnGmy0cb9N2uaqyuzWdPZai+blPq7Mqt4DICnRKeU0MAoeEuSM8ST01zItwrTlsPZNMKEjJ60PqAohWhHHtJuHu0sl6fs2gdrgtGtjBeqRJ9C4iRTlD3PWCqzA9M7+vZhfPzKm3QffOacTpA6k00GSep2yIpko7vcwE7YwclulaSi+RQtwxBoJVK1x3vOrCVN0y4rK4RzbO0rLYByWDARZrzCjmh5Cfjs8vs4VyYAA0t5rDEcnU/mTSjBLT79Mhlzr9b9zpT21FkDphcatJoLbMLVEo02HYs3RzxWp+mtbrwt1hCMHcOdJ328UiA0JiDX1 root@mt102
[root@mt102 ~]#
[root@mt102 ~]#
[root@mt102 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.16.101
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.16.101 (192.168.16.101)' can't be established.
ECDSA key fingerprint is SHA256:oShRek8kc5ZO9vmSnwSPuWxKieGfPuTG8VorbWM6CiE.
ECDSA key fingerprint is MD5:94:44:a1:ea:8c:c9:2b:fd:85:5e:a5:78:2d:1e:b4:53.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.16.101's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.16.101'"
and check to make sure that only the key(s) you wanted were added.
[root@mt102 ~]#
[root@mt102 ~]# ssh 192.168.16.101
Last login: Fri Dec 13 23:20:42 2019
[root@mt101 ~]# exit
logout
Connection to 192.168.16.101 closed.
[root@mt102 ~]#
[root@mt102 ~]# ll .ssh
total 12
-rw------- 1 root root 1679 Dec 11 15:37 id_rsa
-rw-r--r-- 1 root root 392 Dec 11 15:37 id_rsa.pub
-rw-r--r-- 1 root root 176 Dec 13 23:27 known_hosts
[root@mt102 ~]#
[root@mt102 ~]# cat .ssh/known_hosts
192.168.16.101 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMtkxCPeK5boH0UWlpVYqNv3fIqsZSTj+9iW1l6XV6QHavtFg3QPpB37hAd3PIRPdOzIvwEoTWvk3vks2vzTPMI=
[root@mt102 ~]#
Gerrit:192.168.16.101
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ su - root
Password:
Last login: Fri Dec 13 23:27:49 CST 2019 from 192.168.16.102 on pts/1
[root@mt101 ~]#
[root@mt101 ~]# ll .ssh
total 12
-rw------- 1 root root 392 Dec 13 23:27 authorized_keys
-rw------- 1 root root 1679 Dec 11 23:10 id_rsa
-rw-r--r-- 1 root root 392 Dec 11 23:10 id_rsa.pub
[root@mt101 ~]#
[root@mt101 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.16.102
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.16.102 (192.168.16.102)' can't be established.
ECDSA key fingerprint is SHA256:oShRek8kc5ZO9vmSnwSPuWxKieGfPuTG8VorbWM6CiE.
ECDSA key fingerprint is MD5:94:44:a1:ea:8c:c9:2b:fd:85:5e:a5:78:2d:1e:b4:53.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.16.102's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.16.102'"
and check to make sure that only the key(s) you wanted were added.
[root@mt101 ~]#
[root@mt101 ~]# ssh 192.168.16.102
Last login: Fri Dec 13 23:12:23 2019
[root@mt102 ~]# exit
logout
Connection to 192.168.16.102 closed.
[root@mt101 ~]#
[root@mt101 ~]# ll .ssh/
total 16
-rw------- 1 root root 392 Dec 13 23:27 authorized_keys
-rw------- 1 root root 1679 Dec 11 23:10 id_rsa
-rw-r--r-- 1 root root 392 Dec 11 23:10 id_rsa.pub
-rw-r--r-- 1 root root 176 Dec 13 23:31 known_hosts
[root@mt101 ~]#
[root@mt101 ~]# cat .ssh/known_hosts
192.168.16.102 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMtkxCPeK5boH0UWlpVYqNv3fIqsZSTj+9iW1l6XV6QHavtFg3QPpB37hAd3PIRPdOzIvwEoTWvk3vks2vzTPMI=
[root@mt101 ~]#
在Gerrit服务器上编辑用户同步Gitlab的配置文件,需要手动创建
[gerrit@mt101 ~]$ cd gerrit_testsite/etc/
[gerrit@mt101 etc]$ pwd
/home/gerrit/gerrit_testsite/etc
[gerrit@mt101 etc]$
[gerrit@mt101 etc]$ vim .ssh/config
[gerrit@mt101 etc]$ cat .ssh/config
Host 192.168.16.102
IdentityFile ~/.ssh/id_rsa
PreferredAuthentications publickey
[gerrit@mt101 etc]$
[gerrit@mt101 etc]$ ll .ssh/config
-rw------- 1 gerrit gerrit 86 Dec 13 23:37 .ssh/config
[gerrit@mt101 etc]$
3 - 更新Gerrit配置文件
在Gerrit配置文件中添加关于的设置。
replication插件用于实现Gerrit和远程代码仓库的自动同步。
[plugins]
allowRemoteAdmin = true
添加并重启Gerrit服务
[gerrit@mt101 ~]$ sudo vim gerrit_testsite/etc/gerrit.config
[gerrit@mt101 ~]$ sudo cat gerrit_testsite/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://192.168.16.101:8083/
serverId = 0b911b9e-195a-46b0-a5cd-b407b776b344
[container]
javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
user = root
javaHome = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre
[index]
type = lucene
[auth]
type = HTTP
[receive]
enableSignedPush = false
[sendemail]
smtpServer = localhost
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://192.168.16.101:8083/
[cache]
directory = cache
[gitweb]
type = gitweb
cgi = /var/www/git/gitweb.cgi
[plugins]
allowRemoteAdmin = true
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ sudo sh gerrit_testsite/bin/gerrit.sh restart
Stopping Gerrit Code Review: OK
Starting Gerrit Code Review: OK
[gerrit@mt101 ~]$
4 - 在Gerrit中创建项目
4.1 在GitLab中创建一个项目
- 关闭Auto DevOps:Settings---》CI/CD---》Auto DevOps,去除勾选---》Save changes
- 添加ReadMe文件
git@192.168.16.102:root/testrepo.git
4.2 在Gerrit创建一个空项目并同步GitLab
项目名与GitLab项目相同
- 删除自动创建的目录:sudo rm -rf testrepo.git/
- 重新从GitLab复制:git clone --bare git@192.168.16.102:root/testrepo.git
[gerrit@mt101 git]$ pwd
/home/gerrit/gerrit_testsite/git
[gerrit@mt101 git]$
[gerrit@mt101 git]$ ll
total 0
drwxr-xr-x 7 gerrit gerrit 119 Dec 10 14:43 All-Projects.git
drwxr-xr-x 7 gerrit gerrit 119 Dec 11 12:26 All-Users.git
drwxr-xr-x 7 root root 100 Dec 12 14:57 testrepo.git
[gerrit@mt101 git]$
[gerrit@mt101 git]$ sudo rm -rf testrepo.git/
[gerrit@mt101 git]$
[gerrit@mt101 git]$ git clone --bare git@192.168.16.102:root/testrepo.git
Cloning into bare repository 'testrepo.git'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
[gerrit@mt101 git]$
[gerrit@mt101 git]$ ll
total 0
drwxr-xr-x 7 gerrit gerrit 119 Dec 10 14:43 All-Projects.git
drwxr-xr-x 7 gerrit gerrit 119 Dec 11 12:26 All-Users.git
drwxrwxr-x 7 gerrit gerrit 138 Dec 12 15:04 testrepo.git
[gerrit@mt101 git]$
[gerrit@mt101 git]$ ll testrepo.git/
total 16
drwxrwxr-x 2 gerrit gerrit 6 Dec 12 15:04 branches
-rw-rw-r-- 1 gerrit gerrit 128 Dec 12 15:04 config
-rw-rw-r-- 1 gerrit gerrit 73 Dec 12 15:04 description
-rw-rw-r-- 1 gerrit gerrit 23 Dec 12 15:04 HEAD
drwxrwxr-x 2 gerrit gerrit 242 Dec 12 15:04 hooks
drwxrwxr-x 2 gerrit gerrit 21 Dec 12 15:04 info
drwxrwxr-x 4 gerrit gerrit 30 Dec 12 15:04 objects
-rw-rw-r-- 1 gerrit gerrit 98 Dec 12 15:04 packed-refs
drwxrwxr-x 4 gerrit gerrit 31 Dec 12 15:04 refs
[gerrit@mt101 git]$
[gerrit@mt101 git]$ cat testrepo.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = git@192.168.16.102:root/testrepo.git
[gerrit@mt101 git]$
5 - 配置Grerrit与GitLab的同步
5.1 replication插件
通过Gerrit的replication插件来实现。
确认插件状态:已安装、已启用。
[gerrit@mt101 git]$ ssh -p 29418 admin@192.168.16.101 gerrit plugin ls |grep replication
replication v3.1.0 ENABLED replication.jar
[gerrit@mt101 git]$
5.2 配置插件
在/home/gerrit/gerrit_testsite/etc
目录下创建replication.config文件用于代码同步。
特别注意:以后每创建一个新的项目,都要在该配置文件中添加对应的配置。
[gerrit@mt101 etc]$ pwd
/home/gerrit/gerrit_testsite/etc
[gerrit@mt101 etc]$
[gerrit@mt101 etc]$ vim replication.config
[gerrit@mt101 etc]$
[gerrit@mt101 etc]$ cat replication.config
[remote "testrepo"]
projects = testrepo
url = git@192.168.16.102:root/testrepo.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
push = +refs/changes/*:refs/changes/*
threads = 3
[gerrit@mt101 etc]$
[gerrit@mt101 etc]$ ssh -p 29418 admin@192.168.16.101 gerrit plugin reload replication
[gerrit@mt101 etc]$
6 - 本地代码提交测试
6.1 本地设置
- 本地Git用户配置要和Gerrit用户信息一致
- 本地公钥已添加到Gerrit用户配置中
- 本地Git版本不能太低,否则会出现未知的错误
Anliven@Anliven-PC /d/Project/testrepo (master)
λ git config --global user.name "admin"
Anliven@Anliven-PC /d/Project/testrepo (master)
λ git config --global user.email "anliven@126.com"
Anliven@Anliven-PC /d/Project
λ git config --list |grep user
user.name=admin
user.email=anliven@126.com
Anliven@Anliven-PC /d/Project
λ
Anliven@Anliven-PC /d/Project
λ git --version
git version 2.19.0.windows.1
Anliven@Anliven-PC /d/Project
λ
Anliven@Anliven-PC /d/Project
λ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDQSFpwR9eBCTKfTbPEE8TWIo75KfX3AczpXK6nTKGH248pxjfq7cDe2cGj1VOSqknMqvg0g1LLiXrgbIGbtclt49UKSFXxWnVm04rZHVsz9rtfzxuF/NmSqSv7isYLZvwaI4aGXkLwILOemqwCbPRybGlkIiU9sgFK6m5gBWpsA6WqbHGlll8o1jC1cIuiPcJuYwod4+ehI5GvH3Tr3rUjkWy0QEhFfV22Nt79mJ3D+xDpDP/SxhPtPWw1Ob1+10+0+xvSTvGR/gcLUnUXciIooJVSypTPLnGe+d4Y5i+jCzDRIxeXBEQrQXafoxTjPNMb/T84mkPH+MSSTnvAk6Oelcs9MJLDIlXcDGSKXSzl2XmjjiTglq0R5gnRtUL6jxcyR0Db5mEF5maumfyKz58/O5pSDGVRW13O6V0YGq6j8f5mcn8h1usdqabbirUGA5+7OB2Ek4KlLy/U6GkHtr5gY4zch08A8/xWowGppOjb8b/MqxJuLmQY1+vvUlupALd6nNmacugmlZK+ZsheTCJhdNHLBVl40b4UZdbD19LCI5cFonvJP979J4SIc8gHh7SXu7lSTRWciA0BKLrwhhHID1PHnF5o0re4kENZW4LYiXhBo998+7TtXiK+itnjUsfHRDPUvQC0OrhmLf/DAyanpRs65rXFONEaVGf4NS+PCQ== anliven@126.com
Anliven@Anliven-PC /d/Project
λ
6.2 下拉代码
这里使用了SSH方式下的Clone with commit-msg hook模式
Anliven@Anliven-PC /d/Project
λ pwd
/d/Project
Anliven@Anliven-PC /d/Project
λ ll
total 0
drwxr-xr-x 1 Anliven 197121 0 十一 28 00:05 testproject/
Anliven@Anliven-PC /d/Project
λ
Anliven@Anliven-PC /d/Project
λ ll
total 0
drwxr-xr-x 1 Anliven 197121 0 十一 28 00:05 testproject/
Anliven@Anliven-PC /d/Project
λ git clone "ssh://admin@192.168.16.101:29418/testrepo" && scp -p -P 29418 admin@192.168.16.101:hooks/commit-msg "testrepo/.git/hooks/"
Cloning into 'testrepo'...
remote: Counting objects: 12, done
remote: Finding sources: 100% (12/12)
remote: Total 12 (delta 0), reused 12 (delta 0)
Receiving objects: 100% (12/12), done.
commit-msg 100% 1790 297.0KB/s 00:00
Anliven@Anliven-PC /d/Project
λ
Anliven@Anliven-PC /d/Project
λ ll
total 0
drwxr-xr-x 1 Anliven 197121 0 十一 28 00:05 testproject/
drwxr-xr-x 1 Anliven 197121 0 十二 13 23:49 testrepo/
Anliven@Anliven-PC /d/Project
λ ll testrepo/
total 3
-rw-r--r-- 1 Anliven 197121 31 十二 13 23:49 README.md
-rw-r--r-- 1 Anliven 197121 41 十二 13 23:49 testlog.txt
-rw-r--r-- 1 Anliven 197121 9 十二 13 23:49 try.txt
Anliven@Anliven-PC /d/Project
λ
6.3 改动
Anliven@Anliven-PC /d/Project
λ cd testrepo/
Anliven@Anliven-PC /d/Project/testrepo (master)
λ echo "1234567890" >> testlog.txt
Anliven@Anliven-PC /d/Project/testrepo (master)
λ git add *
warning: LF will be replaced by CRLF in testlog.txt.
The file will have its original line endings in your working directory
Anliven@Anliven-PC /d/Project/testrepo (master)
λ git commit -m "update testlog"
[master 6c8f1d2] update testlog
1 file changed, 1 insertion(+)
Anliven@Anliven-PC /d/Project/testrepo (master)
λ
Anliven@Anliven-PC /d/Project/testrepo (master)
λ cat testlog.txt
This is the first change from local PC.
1234567890
Anliven@Anliven-PC /d/Project/testrepo (master)
λ
6.4 提交改动
特别注意:
提交的命令变为“git push -u origin HEAD:refs/for/
“refs/for/*”会将变更提交放到暂存区中,等待代码审核和集成验证
Anliven@Anliven-PC /d/Project/testrepo (master)
λ git push -u origin HEAD:refs/for/master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 387 bytes | 387.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, new: 1, done
remote:
remote: SUCCESS
remote:
remote: http://192.168.16.101:8083/c/testrepo/+/61 update testlog [NEW]
remote:
To ssh://192.168.16.101:29418/testrepo
* [new branch] HEAD -> refs/for/master
Anliven@Anliven-PC /d/Project/testrepo (master)
λ
Anliven@Anliven-PC /d/Project/testrepo (master)
λ git log -1
commit 6c8f1d20f23697d1d677ac86c30120fdd7d20c43 (HEAD -> master)
Author: admin <anliven@126.com>
Date: Fri Dec 13 23:53:08 2019 +0800
update testlog
Change-Id: I3513942d2b6d2b951b3470946170eb706c4ab8d6
Anliven@Anliven-PC /d/Project/testrepo (master)
λ
6.5 在Gerrit查看提交的改动
在登录界面的CHANGES栏目下可以看到提交的状态(Open、Merged和Abandoned)
这里可以看到改动正处于Open状态下。
点击“first change”这个Subject,可以看到具体信息
6.6 在Gerrit进行人工审核
- 默认只有Project Owners和Administrator群组用户拥有“Code-Review”选项+2的权限(提交通过)
- 普通用户的“Code-Review”选项只能选择+1(审核建议)
代码审核无误,点击“Code-Review+2”按钮
点击“Summit”按钮才能进入代码库
查看提交的最终状态
如果提交成功,页面History部分会出现“Change has been successfully merged”信息
点击页面中gitweb链接,可以直观的看到相关具体信息
CHANGES下的Merged信息
6.7 在GitLab确认同步信息
在GitLab的Master分支确认代码是否同步
6.8 Replication日志
可以从Replication日志获取同步状态信息。
[gerrit@mt101 ~]$ pwd
/home/gerrit
[gerrit@mt101 ~]$ ll gerrit_testsite/logs/replication_log
-rw-r--r-- 1 root root 1982 Dec 14 00:02 gerrit_testsite/logs/replication_log
[gerrit@mt101 ~]$
成功同步的日志
[2019-12-14 00:02:01,017] [c17c270d] Replication to git@192.168.16.102:root/testrepo.git started...
[2019-12-14 00:02:01,020] [c17c270d] Push to git@192.168.16.102:root/testrepo.git references: [RemoteRefUpdate[remoteName=refs/changes/61/61/meta, NOT_ATTEMPTED, (null)...6f1717ea24e438692c05ce9cb20255506e8167e6, srcRef=refs/changes/61/61/meta, forceUpdate, message=null], RemoteRefUpdate[remoteName=refs/heads/master, NOT_ATTEMPTED, (null)...6c8f1d20f23697d1d677ac86c30120fdd7d20c43, srcRef=refs/heads/master, forceUpdate, message=null]]
[2019-12-14 00:02:22,332] [c17c270d] Replication to git@192.168.16.102:root/testrepo.git completed in 21314ms, 15003ms delay, 0 retries
7 - 问题处理
7.1 问题1 - 执行git commit命令报错
问题现象:执行git commit命令时报错“git: 'interpret-trailers' is not a git command. See 'git --help'.”
[gerrit@mt101 testrepo]$ git commit -m "a new file"
git: 'interpret-trailers' is not a git command. See 'git --help'.
cannot insert change-id line in .git/COMMIT_EDITMSG
[gerrit@mt101 testrepo]$
[gerrit@mt101 testrepo]$ git --version
git version 1.8.3.1
[gerrit@mt101 testrepo]$
问题分析:Git版本版本太低导致。
处理方法:在不影响业务的情况下,升级git版本。
参考信息:https://blog.csdn.net/a10703060237/article/details/89704924
7.2 问题2:在本地执行“git clone”命令拉取代码时报错
问题现象:提示“Could not read from remote repository. ”
Anliven@Anliven-PC /d/Project
λ git clone "ssh://admin@192.168.16.101:29418/testrepo"
Cloning into 'testrepo'...
ssh: connect to host 192.168.16.101 port 29418: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
问题分析:经排查,确认防火墙未开放端口,网络不通导致。
处理方法:防火墙开放端口,重新拉取代码。
[gerrit@mt101 ~]$ sudo firewall-cmd --zone=public --permanent --add-port=29418/tcp
success
[gerrit@mt101 ~]$ sudo firewall-cmd --reload
success
[gerrit@mt101 ~]$
8 - 参考信息
CI持续集成系统环境--Gitlab+Gerrit+Jenkins完整对接:https://www.cnblogs.com/kevingrace/p/5651447.html
- 部署gerrit环境完整记录:https://www.cnblogs.com/kevingrace/p/5624122.html
- 部署Gitlab环境完整记录:https://www.cnblogs.com/kevingrace/p/5651402.html
- 部署Jenkins完整记录:https://www.cnblogs.com/kevingrace/p/5651427.html
行动是绝望的解药!
欢迎转载和引用,但请在明显处保留原文链接和原作者信息!
本博客内容多为个人工作与学习的记录,少数内容来自于网络并略有修改,已尽力标明原文链接和转载说明。如有冒犯,即刻删除!
以所舍,求所得,有所获,方所成。