Install and deploy Gerrit under Ubuntu

1. a brief introdction##

  1. Before git add-->git commit-->git push the orange line in the figure

  2. Gerrit is the bird in the picture above. The code of ordinary members is first pushed to the gerrit server, and then the code reviewer, the integrator in the upper left corner, performs the code review (review) on the web page. After passing (approve), this time the code will be submitted (submit) to the code repository (repo).

  3. Code review passed or rejected, the code submitter (Contributor) and all related code reviewers (Integrator) will receive email reminders

  4. Gerrit also has an automatic test function. Code that conflicts with the main line or fails the test will be directly rejected. This function seems to be the task of the old man (Jenkins) in the lower right corner.

  5. When doing commit, a Change-Id must be generated, otherwise, when pushing to the gerrit server, you will receive an error reminder

  6. The committer cannot directly push the code to the remote master mainline (or other remote branches). This is equivalent to crossing gerrit. Gerrit must depend on a branch of refs/for/*.

If we have only one master mainline remotely, then only when your code is submitted to the refs/for/master branch, gerrit will know that I have received a code push that needs to be reviewed, and I need to notify the reviewer to review the code .

After the review is passed, gerrit will automatically merge this branch into the master main line, and then notify the relevant members by email that there is an update to the master branch, and the members that need it will be pulled. And this branch of refs/for/master is transparent, which means that ordinary members do not need to know this line. If you configure sourceTree correctly, you should not see this line. of

2. Installation process##

2.1 ubuntu system####

For convenience, I use the installation on the VMware Workstation Pro virtual machine, and ubuntu can go directly to the official website to download. The installation steps are straightforward. After installation, change the language to Chinese. The Ubuntu terminal supports Chinese display and switch input methods. ;

2.2 root

When the system is ready, you must first root to install subsequent support packages/programs/create users, etc.

sudo passwd
# [ sudo]Tw password: sudo is actually a root command of Ubuntu, just enter your password and press Enter
# After creating
su - #Switch to root user
# root@ubuntu:~#Is the successful switching

Let me post the instructions that I will use frequently in the follow-up

sudo apt-get update update source
sudo apt-get install package install package
sudo apt-get remove package delete package
sudo apt-get upgrade Update installed packages
mkdir -p code/string  #Create a new string folder plus-p means that you can praise the directory operation or add it to the current directory
touch code/string/lesson.js  #New lesson.js file
sudo rm -rf  +Files to be deleted
vim editing commands, used when you need to edit a text
  i  + Esc +Shift ZZ save edit
  i + Esc + :+! Do not save edits
cat view
whereis +File name to be queried#search for

# Important, need to start every time#
   /home/gerrit/gerrit_site/bin/gerrit.sh restart restart gerrit
   service nginx restart restart nginx
# important#

2.3 Installer/package####

2.3.1 git
sudo apt-get update
sudo apt-get install git
2.3.2 vim
sudo apt install vim
2.3.3 JDK assistance
apt-cache search openjdk
sudo apt-get install openjdk-8-jdk
vim ~/.bashrc
java -versionjava
2.3.4 Nginx
sudo apt install nginx
sudo systemctl status nginx
service nginx restart

nginx needs to create a new configuration file /etc/nginx/conf.d/gerrit.conf

server {
  listen *:81;
  server_name gerrit.microwu.com;
  allow   all;
  deny    all;
  auth_basic "Welcomme to Gerrit Code Review Site!";
  auth_basic_user_file /home/gerrit/gerrit.password;
  location /{
  proxy_pass  http://127.0.0.1:8080;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header Host $host;}}
2.3.5 C environment#####
sudo apt-get install gcc-5
sudo apt-get install g++-5
sudo apt-get install build-essential
2.3.6 make
sudo apt-get install ubuntu-make
2.3.7 netstat
sudo apt-get install net-tools
2.3.8 Apache
sudo apt install apache2
sudo apt install apache2-utils
2.3.9 php
sudo apt-get install libxml2-dev
sudo apt-get install libbz2-dev

Download the self-built catalog

cd php-5.5.13./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization
- - disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm
- - with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd
- - with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring
- - with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap
- - with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem
- - enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2
- - with-readline --without-sqlite3 --without-pdo-sqlite --with-pear

2.4. gerrit install

adduser gerrit
su gerrit

Download the installation package and copy it to /home/gerrit/

java -jar gerrit-2.13.4.war init -d ~/gerrit_site  #Unzip and install

The installation process only needs to see the input of http when configuring the Authenticationmethod and press Enter for all others; create a new user in the directory /home/gerrit/

$ htpasswd -c /home/gerrit/gerrit.password admin
$ htpasswd -m /home/gerrit/gerrit.password master

Modify the gerrit configuration file /home/gerrit/gerrit_site/etc/gerrit.config, my configuration file for reference and comparison

[ gerrit]
 basePath = git
 serverId = bd3a7d07-58c8-42ac-8a0d-5d8d205ed3fb
 canonicalWebUrl = http://http://192.168.96.130:8080/[database]
 type = h2
 database =/home/gerrit/gerrit_site/db/ReviewDB
[ noteDb "changes"]
 disableReviewDb =true
 primaryStorage = note db
 read =true
 sequence =true
 write =true[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-8-openjdk-amd64/jre
[ index]
 type = LUCENE
[ auth]
 type = HTTP
[ receive]
 enableSignedPush =false[sendemail]
 smtpServer = smtp.ym.163.com
 smtpServerPort =25
 smtpEncryption = SSL
 smtpUser = [email protected]
 smtpPass = xiangy1234
 from= [email protected]
[ sshd]
 listenAddress =*:29418[httpd]
 listenUrl = http://*:8080/
[ cache]
 directory = cache

If it is installed step by step, I only need to modify the sendemail content, here is the content of the configuration mailbox, because the 163 mailbox used by our department is configured according to the 163 stmp content; after configuration, restart gerrit and nginx ;

/home/gerrit/gerrit_site/bin/gerrit.sh restart restart gerrit
   service nginx restart restart nginx

Check the port information after restarting for reference

netstat -ltpn
 PID/Program name
tcp        000.0.0.0:800.0.0.0:*               LISTEN      26246/nginx: master
tcp        000.0.0.0:810.0.0.0:*               LISTEN      26246/nginx: master
tcp        00127.0.0.53:530.0.0.0:*               LISTEN      107306/systemd-reso
tcp        00127.0.0.1:6310.0.0.0:*               LISTEN      25265/cupsd
tcp6       00:::29418:::*                    LISTEN      26454/GerritCodeRev 
tcp6       00:::8080:::*                    LISTEN      26454/GerritCodeRev 
tcp6       00:::80:::*                    LISTEN      26246/nginx: master
tcp6       00::1:631:::*                    LISTEN      25265/cupsd

After confirming that gerrit and nginx have port information, open the browser and enter your ip:81, a login window will be displayed first

Enter the admin account and password

Displaying this interface indicates that the deployment of the gerrit environment is complete!

# Attached delete method#

/home/gerrit/gerrit_site/bin/gerrit.sh stop
Then delete it directly/home/gerrit/gerrit_site/Entire folder
$ ps -ef | grep gerrit

Recommended Posts

Install and deploy Gerrit under Ubuntu
Install nodejs and npm under Ubuntu 16.04
Compile and install QEMU under Ubuntu
Install node.js under Ubuntu
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
[python] python2 and python3 under ubuntu
2018-09-11 Install arduino under Ubuntu
Install ROS under ROS Ubuntu 18.04[2]
Install MySQL under Ubuntu
Install Yarm-PM2 under Ubuntu
Deploy FTP server under ubuntu
Ubuntu 16.04 compile and install PHP 7.2
ubuntu install and configure GitLab
Install server-side Shadowsocks under Ubuntu 16.04
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
Install rgl package under Ubuntu
Install win7 and archlinux on hard disk under ubuntu
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Cpp web (1) Install and use Crow service under Ubuntu
Install and configure keepalived under CentOS 5.9
Install and use dig under ubuntu/debian
Talk about | Install and use Linux system Ubuntu under Win10
Compile and install LAMP under Centos 5.2
Install and configure MySQL on Ubuntu
Deploy the mail system under Ubuntu 19.10
Install and configure Docker in Ubuntu
[Daily] Install php pdo extension and import database under ubuntu
Deploy and optimize Tomcat under Centos
Install MySQL under Ubuntu 18.04 (graphic tutorial)
Install JDK1.8 original under Ubuntu Kylin
Redis installation under ubuntu and windows
Small tool: install screenshot tool under ubuntu
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
Install Python3 and Py under CentOS7
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
How to install Audacious under Ubuntu
How to install Tensorflow under ubuntu 16.04
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Install the latest version of Thunderbird and exchange plugins under ubuntu
Install Gnome and VNC on Ubuntu Server
Compile and install libmodbus library under CentOS7
51 MCU program development and download under Ubuntu
[Daily] Win10 open and install ubuntu subsystem
Ubuntu install Elasticsearch and elasticsearch-analysis-ik word segmentation
Installation and uninstallation of CUDA under Ubuntu 16.04
Install docker on ubuntu and basic usage
Install fonts on Ubuntu and switch default fonts
Install YouCompleteMe plugin for vim under Ubuntu
Ubuntu install PHP and PHP Nginx configuration method
Install PyTesser under ubuntu 14.04 for OCR recognition
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
Install and uninstall CUDA and CUDNN on Ubuntu
Deploy python3 and nginx projects on ubuntu18.04
Install Ubuntu with Parallels Desktop under Mac
Three ways to install software under Ubuntu
Install utility software collection under Ubuntu system