Gerrit分布式实现
gerrit不支持jre1.8以上版本
思路
查看gerrit源代码,把gerrit依赖单机的代码内容,修改为依赖分布式机器的内容; 这样做到应用本身无存储状态,容器化后可以做到随便创建和删除。
CodeReview相关工具:https://github.com/GerritCodeReview
gerrit版本变更:https://www.gerritcodereview.com/releases-readme.html
gerrit源码:
https://gerrit.googlesource.com/gerrit/
https://github.com/GerritCodeReview/gerrit
构建工具:google内部使用的 bazel bazel安装:https://docs.bazel.build/versions/master/install-os-x.html#install-on-mac-os-x-homebrew bazel介绍:https://www.cnblogs.com/Leo_wl/p/4458115.html
官网
内容:
- 插件链接
- 下载地址
- 在线ppt,解释gerrit的理念
- 线文档
build gerrit source code
Gerrit Code Review - Building with Bazel Gerrit Code Review - IntelliJ IDEA Setup
git clone --recursive https://gerrit.googlesource.com/gerrit
cd gerrit && bazel build release
上面执行成功的话,会在gerrit目录生成如下war包
bazel-bin/release.war
cd gerrit && bazel build gerrit
上面执行成功的话,会在gerrit目录生成如下war包
bazel-bin/gerrit.war
[切换分支](http://127.0.0.1:8080/Documentation/dev-readme.html#_switching_between_branches)要把子模块一起切换
git checkout --recurse-submodules
debug the Gerrit server
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
gerrit初始化配置
http://127.0.0.1:8080/Documentation/config-gerrit.html#_file_etcgerrit_config
安装
On CentOS/RedHat run:
yum clean all && yum install gerrit-<version>[-<release>]
gerrit前端开发
k8s部署方案
google内部源 https://gerrit.googlesource.com/k8s-gerrit/
对应的github源: https://github.com/GerritCodeReview/k8s-gerrit
gerrit的docker镜像
https://hub.docker.com/r/gerritforge/gerrit-centos7/tags
To run a CentOS 7 based Gerrit image:
docker run -p 8080:8080 gerritforge/gerrit-centos7[:version]
使用idea+bazel开发
bazel插件也是bazel构建的,详见github
在线试用
https://gerrit-review.googlesource.com/dashboard/self
插件
打包方法
注意:
- 一定要开代理
- 保持插件和gerrit的版本一致性,避免版本不兼容
- 插件无法单独打包,必须把插件的代码放到gerrit/plugins/目录下,按照如下方式进行打包
The fact that plugin contains BUILD file doesn’t mean that building this plugin from the plugin directory works.
Bazel in tree driven means it can only be built from within Gerrit tree. Clone or link the plugin into gerrit/plugins directory:
cd gerrit
bazel build plugins/<plugin-name>:<plugin-name>
The output can be normally found in the following directory:
bazel-bin/plugins/<plugin-name>/<plugin-name>.jar
Some plugins describe their build process in src/main/resources/Documentation/build.md file. It may worth checking.
首先配置
Open YOUR_GERRIT_DIR/etc/gerrit.config file and add the following entry:
[plugins]
allowRemoteAdmin = true
然后远程安装插件,注意符号: <
ssh -p 29418 admin@172.19.16.64 gerrit plugin install -n replication.jar - <~/temp/replication.jar
远程重载/删除/使能插件
ssh -p 29418 admin@172.19.16.64 gerrit plugin reload/rm/enable replication