Gerrit – Installation and setup

来源:互联网 发布:瓷妆口红怎么样 知乎 编辑:程序博客网 时间:2024/05/01 22:10

refs:

http://codingbee.net/tutorials/gerrit/gerrit-installation-setup/



Intro

Gerrit is a code review tool. To learn more about it, check out theThe Gerrit Book. This books has a lot of useful guides including how to automate code review usingJenkins.

This guide covers how to install/setup gerrit on Linux distro, CentOS.

Set up the database

Gerrit by default will create the “h2” database for you as part of it’s installation process. However if you want to use an alternative/seperate db technology , then this db needs to be created beforehand. In my case I will be using a postgresql db, so I will be referring to postgres for the rest of this article.

You can create install/setup postgresql in a seperate server, or install/setup in the same server that gerrit will be installed on. For resilience purposes it is best practice to have a seperate gerrit-server, and a seperate postgresql-server.

From Puppet automation perspective, the postgresql server needs to be built before the gerrit server. I don’t think puppet allows “node ordering”, but we can insert a check in the gerrit-puppet-module to check connectivity with postgresql db and error out if that fails, which would happen if postgres server doesn’t exist, or if postgres exists but gerrit-server hasn’t been authenticated to communicated with the postgres server.

Therefore before I can move on to the next section, I need to first install PostgreSQL on a separate server, create a new db, create a new db user account, and finally the db user full privelege to the db.

Create the Gerrit user

You need to install gerrit using a user called “gerrit”.

You can create the gerrit user in the same way as any other user “using the useradd”, command, However it best practice to set the home directory of this user to:

/opt/gerrit   # this will get created automatically as part of the useradd command. 

You need to set a password for the gerrit user, this is not essential but let’s you login as gerrit user directly rather than doing “su -” from root user.

Hence, lets create a new user called “gerrit” and set it’s home directory to be /opt/gerrit:

[root@puppetagent02 ~]# useradd -d /opt/gerrit gerrit[root@puppetagent01 /]#  cat etc/passwd | grep "gerrit"gerrit:x:501:502::/opt/gerrit:/bin/bash

Note, this will create the “/opt” folder along with the “/opt/gerrit” folder.

As root user, you can then run “passwd gerrit” to set a password for gerrit, but we won’t bother with that.

Install dependant packages

Before you can install gerrit, your machine must have:

java jdk v1.8

You can check which version you have like this:

[root@puppetagent02 etc]$ java -versionopenjdk version "1.8.0_31"OpenJDK Runtime Environment (build 1.8.0_31-b13)OpenJDK 64-Bit Server VM (build 25.31-b07, mixed mode)

if not installed install it via the command line:

[root@puppetagent02 etc]$ yum install java-1.8.0-openjdk.x86_64

Git v1.6+

You can check this like this:

[gerrit@puppetagent02 etc]$ git --versiongit version 1.7.1[gerrit@puppetagent02 etc]$

If you don’t have this, the you can use yum:

$ yum install git

gitweb

This is done using:

$ yum install gitweb

Installing gitweb will result in the following file becoming available:

/var/lib/gitweb.cgi    # Not sure if this path is correct.

You need to keep a note of this so that you can have gitweb managed internally by gerrit. You then configure gitweb in the gerrit.config file by inserting the following:

[gitweb]    cgi = /var/lib/gitweb.cgi

Note: you don’t need to change any gitweb specific configurations.

Linux utilities

This is automatically true if installing Gerrit on Linux, but not so on Windows. Hence if you are installing gerrit on a linux machine, then you can ignore this requirement.

Download the gerrit installation file

login as the gerrit user:

[root@puppetagent02 ~]# su - gerrit[gerrit@puppetagent02 ~]$

and downlaod file from:

https://gerrit-releases.storage.googleapis.com/index.html

by using curl:

[gerrit@puppetagent02 ~]$ pwd/opt/gerrit[gerrit@puppetagent02 ~]$ curl https://gerrit-releases.storage.googleapis.com/gerrit-2.10.war -o gerrit.war  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed100 39.4M  100 39.4M    0     0   853k      0  0:00:47  0:00:47 --:--:-- 1042k[gerrit@puppetagent02 ~]$ ls -ltotal 40392-rw-rw-r-- 1 gerrit gerrit 41360250 Feb 24 12:23 gerrit.war

Note, we download this war into the gerrit user’s home directory.

Install Gerrit

Note, if you already have a pre-prepared gerrit.config and secure.config, then you can do a silent or semin-automated install. In which case you can skip this section.

You need to be logged in as the gerrit user to Install this war:

[gerrit@puppetagent01 ~]$ iduid=501(gerrit) gid=502(gerrit) groups=502(gerrit)[gerrit@puppetagent01 ~]$ pwd/opt/gerrit[gerrit@puppetagent01 ~]$ lsgerrit.war[gerrit@puppetagent01 ~]$ java -jar gerrit.warGerrit Code Reviewusage: java -jar gerrit.war command [ARG ...]The most commonly used commands are:  init           Initialize a Gerrit installation  reindex        Rebuild the secondary index  daemon         Run the Gerrit network daemons  gsql           Run the interactive query console  version        Display the build version number  ls             List files available for cat  cat FILE       Display a file from the archive

Here we there are a number of options of which we are going to use init:

Note: run the “init” command as the gerrit user.

[gerrit@puppetagent01 ~]$ java -jar gerrit.war init     # Run the "init" command as the gerrit user. *** Gerrit Code Review 2.10****** Git Repositories***Location of Git repositories   [git]:

If you accept the “git” defaults, then it will create the following folder:

[root@puppetagent01 gerrit]# tree.├── bin├── data├── etc│   └── mail├── gerrit.war├── lib├── logs├── plugins├── static└── tmp9 directories, 1 file[root@puppetagent01 gerrit]# tree.├── bin├── data├── etc│   └── mail├── gerrit.war├── git                       # this folder is now created. ├── lib├── logs├── plugins├── static└── tmp10 directories, 1 file[root@puppetagent01 gerrit]#

Next we need to do accept the default “h2”:

This will result in the “db” folder being created:

[root@puppetagent01 gerrit]# tree.├── bin├── data├── db             # this folder gets created. ├── etc│   └── mail├── gerrit.war├── git├── lib├── logs├── plugins├── static└── tmp11 directories, 1 file[root@puppetagent01 gerrit]#

Now we accept the default “LUCENE licence”. This doesnt create any new files/folders.

The same is true of “OPENID”, note this includes “?” option which might prompt you to try a few things.

Keep accepting defaults, when you reach and say yes to the following…:

Copy gerrit.war to /opt/gerrit/bin/gerrit.war [Y/n]? Y

You get the following new item:

[root@puppetagent01 gerrit]# tree.├── bin│   └── gerrit.war          # new file here. ├── data├── db├── etc│   └── mail├── gerrit.war├── git├── lib├── logs├── plugins├── static└── tmp11 directories, 2 files[root@puppetagent01 gerrit]#

Also for now, select “no” for the “bouncy castle” option. By selecting no, this will create the following folder:

[root@puppetagent01 gerrit]# tree.├── bin│   └── gerrit.war├── data├── db├── etc│   ├── mail│   └── ssh_host_key   # this file is created. ├── gerrit.war├── git├── lib├── logs├── plugins├── static└── tmp11 directories, 3 files

Now it will give you the option to install/uninstall various plugins. These are temporarily placed in the local tmp folder:

[root@puppetagent01 gerrit]# tree.├── bin│   └── gerrit.war├── cache├── data├── db├── etc│   ├── mail│   └── ssh_host_key├── gerrit.war├── git├── lib├── logs├── plugins├── static└── tmp    ├── plugin_download-commands_150203_1501_1069983237733257196.jar    ├── plugin_replication_150203_1501_3947389358378156958.jar    ├── plugin_reviewnotes_150203_1501_7127427235158661758.jar    └── plugin_singleusergroup_150203_1501_439039537351044470.jar12 directories, 7 files

Now when we select no to each of these, they will get deleted from this directory.

However if we say yes to any of them, then they get moved to the plugins folder:

[root@puppetagent01 gerrit]# tree.├── bin│   └── gerrit.war├── cache├── data├── db├── etc│   ├── mail│   └── ssh_host_key├── gerrit.war├── git├── lib├── logs├── plugins│   └── download-commands.jar    # we said yes to this plugin. That's why it is here. ├── static└── tmp    ├── plugin_replication_150203_1501_3947389358378156958.jar    ├── plugin_reviewnotes_150203_1501_7127427235158661758.jar    └── plugin_singleusergroup_150203_1501_439039537351044470.jar12 directories, 7 files[root@puppetagent01 gerrit]#

Here are the values I entered during the interactive prompts of my install:

[gerrit@puppetagent01 ~]$ java -jar gerrit.war init   # Run the "init" command as the gerrit user. *** Gerrit Code Review 2.10****** Git Repositories***Location of Git repositories   [git]:*** SQL Database***Database server type           [h2]:*** Index***Type                           [LUCENE/?]:The index must be rebuilt before starting Gerrit:  java -jar gerrit.war reindex -d site_path*** User Authentication***Authentication method          [OPENID/?]:*** Review Labels***Install Verified label         [y/N]? y*** Email Delivery***SMTP server hostname           [localhost]:SMTP server port               [(default)]:SMTP encryption                [NONE/?]:SMTP username                  :*** Container Process***Run as                         [gerrit]:Java runtime                   [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre]:Copy gerrit.war to /opt/gerrit/bin/gerrit.war [Y/n]? YCopying gerrit.war to /opt/gerrit/bin/gerrit.war*** SSH Daemon***Listen on address              [*]:Listen on port                 [29418]:Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v149  If available, Gerrit can take advantage of features  in the library, but will also function without it.Download and install it now [Y/n]? nGenerating SSH host key ... rsa(simple)... done*** HTTP Daemon***Behind reverse proxy           [y/N]?Use SSL (https://)             [y/N]?Listen on address              [*]:Listen on port                 [8080]:Canonical URL                  [http://puppetagent01.co.uk:8080/]:*** Plugins***Install plugin commit-message-length-validator version v2.10 [y/N]? NInstall plugin download-commands version v2.10 [y/N]? yInstall plugin replication version v2.10 [y/N]? nInstall plugin reviewnotes version v2.10 [y/N]? NInstall plugin singleusergroup version v2.10 [y/N]? NInitialized /opt/gerrit[gerrit@puppetagent01 ~]$

All the info that you entered via the interactive mode (with exception of password data), is used to generate a the following config files:

[gerrit@puppetagent02 etc]$ pwd/opt/gerrit/etc[gerrit@puppetagent02 etc]$ ls -ltotal 16-rw-rw-r-- 1 gerrit gerrit  650 Feb 13 07:07 gerrit.config      # this filedrwxrwxr-x 2 gerrit gerrit 4096 Feb 11 11:52 mail-rw------- 1 gerrit gerrit  215 Feb 11 11:52 secure.config      # this stores the ldab and db credentials-rw------- 1 gerrit gerrit 1219 Feb 11 11:52 ssh_host_key[gerrit@puppetagent02 etc]$

These 2 files are useful if you want install gerrit without any interactive prompts (i.e. a silent gerrit install), or semi-automated install, which involves just accepting the defaults.

There is a huge amount various configurations that you can set in the gerrit.config file, to see them, checkout thegerrit.config documentation.

Silent or Semi-automated Gerrit Instalation

To do the silent install, You first need to place your gerrit.war and pre-prepared gerrit.config file in the following folder:

[gerrit@puppetagent02 ~]$ pwd/opt/gerrit[gerrit@puppetagent02 ~]$ ls -ltotal 40400-rwxrwxr-x 1 gerrit gerrit      650 Feb 24 12:55 gerrit.config-rw-rw-r-- 1 gerrit gerrit 41360250 Feb 24 12:54 gerrit.war-rwxrwxr-x 1 gerrit gerrit      215 Feb 24 12:55 secure.config

Now, if you are doing the installation on a VM, then now is a good time to take aVM snapshot!!!

After that you need to go into that directory and run the following to do a silent install:

java -jar gerrit.war init --batch --site-path /opt/gerrit

Note: you omit “–batch” if you want to do a semi-automated install. Where you can see each of them settings and default values.

Here’s an example of this:

[gerrit@puppetagent02 ~]$ pwd/opt/gerrit[gerrit@puppetagent02 ~]$ ls -ltotal 40396-rwxr-xr-x 1 root root      488 Feb 10 14:11 gerrit.config-rw-r--r-- 1 root root 41360250 Feb  4 09:09 gerrit.war-rw-r--r-- 1 root root      215 Feb  4 09:09 secure.config[gerrit@puppetagent02 ~]$ java -jar gerrit.war init --batch --site-path /opt/gerritGenerating SSH host key ... rsa(simple)... doneInitialized /opt/gerrit

After that has run, you should find your config files here now:

[gerrit@puppetagent02 etc]$ pwd/opt/gerrit/etc[gerrit@puppetagent02 etc]$ ls -ltotal 16-rwxrwxr-x 1 gerrit gerrit  650 Feb 24 12:55 gerrit.configdrwxrwxr-x 2 gerrit gerrit 4096 Feb 24 13:05 mail-rw------- 1 gerrit gerrit  170 Feb 24 13:06 secure.config-rw------- 1 gerrit gerrit 1219 Feb 24 13:05 ssh_host_key

Note: The content on the secure.config may have changed during the installation, if so then overwrite the secure.config file with your pre-prepared config file.

[gerrit@puppetagent02 etc]$ pwd/opt/gerrit/etc[gerrit@puppetagent02 etc]$ ls -ltotal 16-rwxrwxr-x 1 gerrit gerrit  650 Feb 24 12:55 gerrit.configdrwxrwxr-x 2 gerrit gerrit 4096 Feb 24 13:05 mail-rw------- 1 gerrit gerrit  170 Feb 24 13:06 secure.config-rw------- 1 gerrit gerrit 1219 Feb 24 13:05 ssh_host_key[gerrit@puppetagent02 etc]$ cp /tmp/secure.config .[gerrit@puppetagent02 etc]$ ls -ltotal 16-rwxrwxr-x 1 gerrit gerrit  650 Feb 24 12:55 gerrit.configdrwxrwxr-x 2 gerrit gerrit 4096 Feb 24 13:05 mail-rw------- 1 gerrit gerrit  215 Feb 24 13:09 secure.config-rw------- 1 gerrit gerrit 1219 Feb 24 13:05 ssh_host_key[gerrit@puppetagent02 etc]$

In my case I had kept a backup of my secure.config file in the /tmp/ folder.

Convert the Gerrit shell script into a service

Return back to the root user:

[gerrit@puppetagent02 etc]$ exitlogout[root@puppetagent02 ~]#

This was done by first running the following commands to create symbolic links:

Note: creating symbolic link isn’t the best approach. So please ignore this.

sudo ln -snf /opt/gerrit/bin/gerrit.sh /etc/init.d/gerrit   # ignore this

Note: I think you need to do this as the root user.

Instead of creating the symbolic link, as shown above, actually make a copy of this file (and get rid of the “.sh” suffix):

[root@puppetagent02 /]# cp /opt/gerrit/bin/gerrit.sh /etc/init.d/gerrit

Make sure it has execute permission:

[root@puppetagent02 init.d]# ls -l gerrittotal 248-rwxr-xr-x  1 root root 14638 Feb 24 15:09 gerrit

Next run:

[root@puppetagent02 init.d]# chkconfig --add gerrit

After that you should be able to do:

[root@puppetagent02 init.d]# chkconfig --list gerritgerrit          0:off   1:off   2:on    3:on    4:on    5:on    6:off

Then start up on all run-levels, you do:

[root@puppetagent02 init.d]# chkconfig --level 0123456 gerrit on[root@puppetagent02 init.d]# chkconfig --list gerritgerrit          0:on    1:on    2:on    3:on    4:on    5:on    6:on[root@puppetagent02 init.d]#

Now let’s try using the service command, and you might get the following error message:

[gerrit@puppetagent02 etc]$ service gerrit status** ERROR: GERRIT_SITE not set[gerrit@puppetagent02 etc]$ 

If you look inside the actual gerrit.sh script, it advises you to create the file, /etc/default/gerritcodereview, and store any gerrit specific environment variables in it, i.e.:

[root@puppetagent02 default]# pwd/etc/default[root@puppetagent02 default]# ls -ltotal 8-rw-r--r--. 1 root root 1756 Nov 21  2013 nss-rw-------. 1 root root  119 Oct 13  2011 useradd[root@puppetagent02 default]# echo "GERRIT_SITE=/opt/gerrit" > /etc/default/gerritcodereview[root@puppetagent02 default]# ls -ltotal 12-rw-r--r--  1 root root   24 Feb 24 13:16 gerritcodereview-rw-r--r--. 1 root root 1756 Nov 21  2013 nss-rw-------. 1 root root  119 Oct 13  2011 useradd[root@puppetagent02 default]#

Note: you need to do this as the root user, since the gerrit user only has read permissions for this folder.

Now if we try the service command again:

[root@puppetagent02 default]# service gerrit statusChecking arguments to Gerrit Code Review:  GERRIT_SITE     =  /opt/gerrit  GERRIT_CONFIG   =  /opt/gerrit/etc/gerrit.config  GERRIT_PID      =  /opt/gerrit/logs/gerrit.pid  GERRIT_TMP      =  /opt/gerrit/tmp  GERRIT_WAR      =  /opt/gerrit/bin/gerrit.war  GERRIT_FDS      =  1024  GERRIT_USER     =  gerrit  JAVA            =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre/bin/java  JAVA_OPTIONS    =  RUN_EXEC        =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview  RUN_ARGS        =  -jar /opt/gerrit/bin/gerrit.war daemon -d /opt/gerrit[root@puppetagent02 default]#

Success!!!

Now we need to start the service:

[root@puppetagent02 default]# service gerrit startStarting Gerrit Code Review: FAILED

However if it fails to start, for example above, then check gerrit’s error log, which you can find here:

[gerrit@puppetagent02 logs]$ pwd/opt/gerrit/logs[gerrit@puppetagent02 logs]$ ls error_logerror_log[gerrit@puppetagent02 logs]$

A common error you might have is to do with reindexing, which we’ll cover next:

do the reindexing

This step is optional and you may need to do this if your gerrit service failed to start. Check your gerrit logfile:

cat /opt/gerrit/logs/error_log

If it contains the following error message:

1) No index versions ready; run Reindex

Then you fix this by doing a reindexing, which is done by simply running the following command:

[gerrit@puppetagent02 ~]$ java -jar gerrit.war reindex

Then try starting the service again:

[gerrit@puppetagent02 ~]$ service gerrit startStarting Gerrit Code Review: OK[gerrit@puppetagent02 ~]$ service gerrit statusChecking arguments to Gerrit Code Review:  GERRIT_SITE     =  /opt/gerrit  GERRIT_CONFIG   =  /opt/gerrit/etc/gerrit.config  GERRIT_PID      =  /opt/gerrit/logs/gerrit.pid  GERRIT_TMP      =  /opt/gerrit/tmp  GERRIT_WAR      =  /opt/gerrit/bin/gerrit.war  GERRIT_FDS      =  1024  GERRIT_USER     =  gerrit  JAVA            =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre/bin/java  JAVA_OPTIONS    =  RUN_EXEC        =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview  RUN_ARGS        =  -jar /opt/gerrit/bin/gerrit.war daemon -d /opt/gerritGerrit running pid=10885[gerrit@puppetagent02 ~]$

Success!!!

Start Gerrit at boot time for all Run Levels

We can also now manage the gerrit service via the service command:

[gerrit@puppetagent02 bin]$ service gerrit stopStopping Gerrit Code Review: OK             # after this the gerrit web insteface also stops working.[gerrit@puppetagent02 bin]$ service gerrit startStarting Gerrit Code Review: OK

One final check we need to do is check that the gerrit service is registered correctly with chkconfig:

[gerrit@puppetagent02 bin]$ chkconfigauditd          0:off   1:off   2:on    3:on    4:on    5:on    6:offblk-availability        0:off   1:on    2:on    3:on    4:on    5:on    6:offcgconfig        0:off   1:off   2:off   3:off   4:off   5:off   6:offcgred           0:off   1:off   2:off   3:off   4:off   5:off   6:offcrond           0:off   1:off   2:on    3:on    4:on    5:on    6:offdocker          0:off   1:off   2:on    3:on    4:on    5:on    6:offgerrit          0:off   1:off   2:off   3:on    4:off   5:off   6:offip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:offiptables        0:off   1:off   2:on    3:on    4:on    5:on    6:offlvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:offlxc             0:off   1:off   2:off   3:off   4:off   5:off   6:offmcollective     0:off   1:off   2:on    3:on    4:on    5:on    6:offnetconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:offnetfs           0:off   1:off   2:off   3:on    4:on    5:on    6:offnetwork         0:off   1:off   2:on    3:on    4:on    5:on    6:offntpd            0:off   1:off   2:off   3:off   4:off   5:off   6:offntpdate         0:off   1:off   2:off   3:off   4:off   5:off   6:offpostfix         0:off   1:off   2:on    3:on    4:on    5:on    6:offpuppet          0:off   1:off   2:off   3:off   4:off   5:off   6:offpuppetmaster    0:off   1:off   2:off   3:off   4:off   5:off   6:offrdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:offrestorecond     0:off   1:off   2:off   3:off   4:off   5:off   6:offrhnsd           0:off   1:off   2:on    3:on    4:on    5:on    6:offrsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:offsaslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:offsshd            0:off   1:off   2:on    3:on    4:on    5:on    6:offudev-post       0:off   1:on    2:on    3:on    4:on    5:on    6:offvboxadd         0:off   1:off   2:on    3:on    4:on    5:on    6:offvboxadd-service 0:off   1:off   2:on    3:on    4:on    5:on    6:offvboxadd-x11     0:off   1:off   2:off   3:on    4:off   5:on    6:off[gerrit@puppetagent02 bin]$

According to this, the gerrit service should start up automatically when the machine is rebooted (and starts up under run level 3).

let’s now reboot the machine. After the reboot, let’s check whether the gerrit service is running:

[gerrit@puppetagent02 ~]$ service gerrit statusChecking arguments to Gerrit Code Review:  GERRIT_SITE     =  /opt/gerrit  GERRIT_CONFIG   =  /opt/gerrit/etc/gerrit.config  GERRIT_PID      =  /opt/gerrit/logs/gerrit.pid  GERRIT_TMP      =  /opt/gerrit/tmp  GERRIT_WAR      =  /opt/gerrit/bin/gerrit.war  GERRIT_FDS      =  1024  GERRIT_USER     =  gerrit  JAVA            =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre/bin/java  JAVA_OPTIONS    =  RUN_EXEC        =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview  RUN_ARGS        =  -jar /opt/gerrit/bin/gerrit.war daemon -d /opt/gerritGerrit running pid=1312

Success!!

Just in case the machine is reboot at a different run level, it may be best to ensure that gerrit starts up in all run levels, which can ensure by running the following command (as root user):

[root@puppetagent02 ~]# chkconfig | grep gerritgerrit          0:off   1:off   2:off   3:on    4:off   5:off   6:off[root@puppetagent02 ~]# chkconfig --level 0123456 gerrit on[root@puppetagent02 ~]# chkconfig | grep gerritgerrit          0:on    1:on    2:on    3:on    4:on    5:on    6:on[root@puppetagent02 ~]#

This is so that the script can be managed via the linux “service” command, e.g. “service gerrit status” and also this will let you configure gerrit to start-up during boot-time.

install Gerrit plugins

There are a bunch of official plugins available here:

https://gerritcodereview-plugins.storage.googleapis.com/index.html

If you want to install/load any of these plugins, you just need to copy the jar files into the following folder:

[gerrit@puppetagent02 plugins]$ pwd/opt/gerrit/plugins/

After that restart the gerrit service:

start the gerrit service

Now start the gerrit service:

/opt/gerrit/bin/gerrit.sh start

Confirm that service is running:

[gerrit@puppetagent01 bin]$ /opt/gerrit/bin/gerrit.sh statusChecking arguments to Gerrit Code Review:  GERRIT_SITE     =  /opt/gerrit  GERRIT_CONFIG   =  /opt/gerrit/etc/gerrit.config  GERRIT_PID      =  /opt/gerrit/logs/gerrit.pid  GERRIT_TMP      =  /opt/gerrit/tmp  GERRIT_WAR      =  /opt/gerrit/bin/gerrit.war  GERRIT_FDS      =  1024  GERRIT_USER     =  gerrit  JAVA            =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre/bin/java  JAVA_OPTIONS    =  RUN_EXEC        =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview  RUN_ARGS        =  -jar /opt/gerrit/bin/gerrit.war daemon -d /opt/gerritGerrit running pid=15768[gerrit@puppetagent01 bin]$

Here’s a different init setup that I also tried out:

[gerrit@puppetagent02 ~]$ java -jar gerrit.war init   # Note: run the "init" command as the gerrit user. *** Gerrit Code Review 2.10****** Git Repositories***Location of Git repositories   [git]:*** SQL Database***Database server type           [h2]:*** Index***Type                           [LUCENE/?]: ?       Supported options are:         lucene         solrType                           [LUCENE/?]: solrSolr Index URL                 [localhost:9983]:The index must be rebuilt before starting Gerrit:  java -jar gerrit.war reindex -d site_path*** User Authentication***Authentication method          [OPENID/?]: ?       Supported options are:         openid         openid_sso         http         http_ldap         client_ssl_cert_ldap         ldap         ldap_bind         custom_extension         development_become_any_accountAuthentication method          [OPENID/?]: development_become_any_account*** Review Labels***Install Verified label         [y/N]? y*** Email Delivery***SMTP server hostname           [localhost]:SMTP server port               [(default)]:SMTP encryption                [NONE/?]: ?       Supported options are:         none         ssl         tlsSMTP encryption                [NONE/?]:SMTP username                  : gerritgerrit's password              :              confirm password :*** Container Process***Run as                         [gerrit]: ?Java runtime                   [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre]:Copy gerrit.war to /opt/gerrit/bin/gerrit.war [Y/n]? YCopying gerrit.war to /opt/gerrit/bin/gerrit.war*** SSH Daemon***Listen on address              [*]:Listen on port                 [29418]:Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v149  If available, Gerrit can take advantage of features  in the library, but will also function without it.Download and install it now [Y/n]? YDownloading http://www.bouncycastle.org/download/bcpkix-jdk15on-149.jar ... OKChecksum bcpkix-jdk15on-149.jar OKGerrit Code Review is not shipped with Bouncy Castle Crypto Provider v149** This library is required by Bouncy Castle Crypto SSL v149. **Download and install it now [Y/n]? YDownloading http://www.bouncycastle.org/download/bcprov-jdk15on-149.jar ... OKChecksum bcprov-jdk15on-149.jar OKGenerating SSH host key ... rsa... dsa... done*** HTTP Daemon***Behind reverse proxy           [y/N]? NUse SSL (https://)             [y/N]? yListen on address              [*]:Listen on port                 [8443]:Canonical URL                  [https://puppetagent02.co.uk:8443/]:Create new self-signed SSL certificate [Y/n]? YCertificate server name        [puppetagent02.co.uk]:Certificate expires in (days)  [365]:*** Plugins***Install plugin commit-message-length-validator version v2.10 [y/N]?Install plugin download-commands version v2.10 [y/N]?Install plugin replication version v2.10 [y/N]?Install plugin reviewnotes version v2.10 [y/N]?Install plugin singleusergroup version v2.10 [y/N]?Initialized /opt/gerrit[gerrit@puppetagent02 ~]$

Supported Databases

If you want to see a list of supported databases. then you can view them during the (init) installation process by typing “?” when prompted to choose a db:

[root@puppetagent02 gerrit]# java -jar gerrit.war init*** Gerrit Code Review 2.10****** Git Repositories***Location of Git repositories   [git]:*** SQL Database***Database server type           [h2]: asdfasdferror: 'asdfasdf' is not a valid choice       Supported options are:         h2         jdbc         maxdb         mysql         oracle         postgresqlDatabase server type           [h2]: ?       Supported options are:         h2         jdbc         maxdb         mysql         oracle         postgresqlDatabase server type           [h2]:
LDAP

here are the prompts you get when choosing the ldap option:

*** User Authentication***Authentication method          [OPENID/?]: ?       Supported options are:         openid         openid_sso         http         http_ldap         client_ssl_cert_ldap         ldap                                # I selected this one         ldap_bind         custom_extension         development_become_any_accountAuthentication method          [OPENID/?]: ldapLDAP server                    [ldap://localhost]:    # I think need to also include port number.LDAP username                  : testtest's password                :              confirm password :Account BaseDN                 : testGroup BaseDN                   [test]: test

Here we have

Note: the db password details are not stored in the gerrit.config, instead it is stored a file called secure.config, which sits alongside the gerrit.config:

[root@puppetagent02 etc]# pwd/opt/gerrit/etc[root@puppetagent02 etc]# ls -ltotal 16-rw-r--r-- 1 root root  539 Feb  5 07:34 gerrit.configdrwxr-xr-x 2 root root 4096 Feb  5 07:34 mail-rw------- 1 root root  191 Feb  5 07:34 secure.config-rw------- 1 root root 1220 Feb  5 07:33 ssh_host_key[root@puppetagent02 etc]#

Automating Gerrit install:

In the above examples, we had an interactive prompt which we had to enter values into. In the end, this resulted in the gerrit installation as well as creation of the gerrit.config file. This config file contains all the information that you entered during the interactive prompts.

If you already have a gerrit.config file, then it is possible to do a “silent install”, i.e. automate the installation using an existing gerrit.config file.

Then start gerrit (you might need to reindex again):

[gerrit@puppetagent02 ~]$ /opt/gerrit/bin/gerrit.sh startStarting Gerrit Code Review: OK

Next, you can check that the gerrit process is running under the gerrit user:

[gerrit@puppetagent02 ~]$ ps -ef | grep "GerritCodeReview" | grep -v "grep"gerrit   10853     1 14 14:37 pts/0    00:00:16 GerritCodeReview -jar /opt/gerrit/bin/gerrit.war daemon -d /opt/gerrit --run-id=1423579028.10832[gerrit@puppetagent02 ~]$

This process id (pid) should match up with:

[gerrit@puppetagent02 ~]$ /opt/gerrit/bin/gerrit.sh statusChecking arguments to Gerrit Code Review:  GERRIT_SITE     =  /opt/gerrit  GERRIT_CONFIG   =  /opt/gerrit/etc/gerrit.config  GERRIT_PID      =  /opt/gerrit/logs/gerrit.pid  GERRIT_TMP      =  /opt/gerrit/tmp  GERRIT_WAR      =  /opt/gerrit/bin/gerrit.war  GERRIT_FDS      =  1024  GERRIT_USER     =  gerrit  JAVA            =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre/bin/java  JAVA_OPTIONS    =  RUN_EXEC        =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview  RUN_ARGS        =  -jar /opt/gerrit/bin/gerrit.war daemon -d /opt/gerritGerrit running pid=10853[gerrit@puppetagent02 ~]$

Tip:

when testing your gerrit web interface on your local machine, you will need to add the following to your window’s host file:

C:\Windows\System32\drivers\etc\hosts

Here you add something like:

{gerrit-server-ip-number}   hostname.co.uk 

see also:

http://gerrit-documentation.googlecode.com/svn/Documentation/2.7/install.html – this explains how to convert the gerrit script into a service.

https://review.gerrithub.io/Documentation/install.html
https://gerrit-documentation.storage.googleapis.com/Documentation/2.10/cmd-index.html
http://gerrit-documentation.googlecode.com/svn/Documentation/2.7/install.html

https://gerrit.libreoffice.org/Documentation/install-quick.html

https://gerrit-review.googlesource.com/Documentation/#_tutorial

http://stackoverflow.com/questions/8584660/how-to-login-gerrit-as-administrator

http://www.google.co.uk/search?hl=en-GB&ie=UTF-8&source=android-browser&q=gerrit+rest&gfe_rd=cr&ei=ozTdVJWfAcnBWJTMgJgJ#safe=off&hl=en-GB&q=gerrit+rest+ssh

https://gerrit-documentation.storage.googleapis.com/Documentation/2.10/cmd-plugin-install.html#_scripting

https://gerrit-documentation.storage.googleapis.com/Documentation/2.10/cmd-index.html

https://gerrit-documentation.storage.googleapis.com/Documentation/2.10/cmd-plugin-reload.html

https://gerrit-documentation.storage.googleapis.com/Documentation/2.10/cmd-plugin-ls.html

https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#plugins

https://gerrit-documentation.storage.googleapis.com/Documentation/2.10/cmd-plugin-install.html

https://gerrit-review.googlesource.com/Documentation/config-gerrit.html


0 0