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 ~]$

Gerrit - Gerrit与GitLab集成的更多相关文章

  1. Gerrit和OpenLDAP服务器集成

    Gerrit和OpenLDAP服务器集成 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装LDAP服务器 详情请参考:https://www.cnblogs.com/yinz ...

  2. Jenkins与Gitlab集成

    一.安装jenkinshttps://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/     #清华yum源 yum -y install java-1.8. ...

  3. 持续集成+自动化部署[代码流水线管理及Jenkins和gitlab集成]

    转载:https://www.abcdocker.com/abcdocker/2065 一.代码流水线管理 Pipeline名词顾名思义就是流水线的意思,因为公司可能会有很多项目.如果使用jenkin ...

  4. LDAP落地实战(三):GitLab集成OpenLDAP认证

    上一篇文章介绍了svn集成OpenLDAP认证,版本控制除了svn外,git目前也被越来越多的开发者所喜爱,本文将介绍GitLab如何集成openldap实现账号认证 GitLab集成OpenLDAP ...

  5. 持续集成与自动化部署---代码流水线管理及Jenkins和gitlab集成

    1.代码流水线管理 Pipeline名词顾名思义就是流水线的意思,因为公司可能会有很多项目.如果使用jenkins构建完成后,开发构建项目需要一项一项点击,比较麻烦.所以出现pipeline名词. 代 ...

  6. Gerrit+replication 同步Gitlab

    配置环境:gerrit 192.168.1.100gitlab 192.168.1.1011.创建秘钥 [root@gerrit ~]# ssh-keygen -m PEM -t rsa 2.添加ho ...

  7. openStack CI(Continuous interaction)/CD(Continuous delivery) Gerrit/Jenkins安装及集成,插件配置

    preFace: CI/CD practice part contains the following action items and fields of expertise: Gerrit ins ...

  8. gitlab 集成Jenkins

    项目:使用git+jenkins实现持续集成 开始构建  General  源码管理 我们安装的是Git插件,还可以安装svn插件  我们将git路径存在这里还需要权限认证,否则会出现error  我 ...

  9. kubernetes实战(十四):k8s持久化部署gitlab集成openLDAP登录

    1.基本概念 使用k8s安装gitlab-ce,采用GlusterFS实现持久化(注意PG使用的是NFS存储,使用动态存储重启postgresql的pod后无法成功启动pg,待解决),并集成了open ...

随机推荐

  1. Spring Boot 之:Actuator 监控

    在 Spring Boot 2.x 中为了安全,Actuator 只开放了两个端点 /actuator/health 和 /actuator/info.可以在配置文件中设置打开. Actuator 默 ...

  2. 开启了wpjam以后网站语言不能设置英文的解决方法

    一位网友问ytkah开启了wpjam以后网站语言不能设置英文了这是什么情况?选择English保存以后还是简体中文,禁用插件再设置语言是可以设为English,好几个站点都是这样 其实很简单,只要把这 ...

  3. <?php return array(

    <?php //test.php return array( 'name' => 'andy', 'sex' => 'male' ); ?> <?php $set = r ...

  4. 每隔15s异步刷新手机页面

    前台异步js发请求代码: <script type="text/javascript"> var lightArr; var lightHistoryArr; /* 每 ...

  5. hdu1010-Tempter of the Bone-(dfs+奇偶剪枝)

    http://acm.hdu.edu.cn/showproblem.php?pid=1010 翻译:有只狗被困了,S是起点,D是门,W是墙不能走,‘ . ’是可以走的路,走一次就会在1秒内坍塌,也就是 ...

  6. docker 服务无法启动

    重装以后仍然不行,dockerd可以运行,但是systemctl start docker.service不行,后来在编辑一个文件时,提示没有空间可以保存,结果一查,发现服务器空间基本占满了, 通过 ...

  7. 【转】FIddler+Proxifer工具对windows PC客户端进行抓包

    开篇:要想实现写爬虫,抓取到数据,首先我们应该分析客户端和服务器的请求/响应,前提就是我们能监控到客户端是如何与服务器交互的,下面来记录下常见的三种情况下的抓包方法 1.PC端浏览器网页抓包网页板抓包 ...

  8. SQL练习题 51题 一刷

    Student表: select * from student; 课程表Course: select * from course; 教师表teacher: select * from teacher; ...

  9. Maven配置文件POM属性最全详解

    注:本文内容来源于: BlueKitty1210 <Maven配置文件POM属性最全详解> <project xmlns="http://maven.apache.org/ ...

  10. SQL进阶-隐式类型转换

    一.隐式类型转换 1.隐式类型转换 隐式类型转换: '; 程序可读性差,且依赖数据库的隐式转换规则,如果数据库升级,则程序可能无法正确执行: 有可能会导致索引失效: 有可能会导致意想不到的结果: 显式 ...