Gerrit

From Wikitech
(Difference between revisions)
Jump to: navigation, search
m (snippet to create SQL user)
(Explain why robots.txt denies everything.)
 
(2 intermediate revisions by one user not shown)
Line 47: Line 47:
 
# Start gerrit with the new *.war file using the "init" flag. For example: <tt>cd /var/lib/gerrit2 && java -jar gerrit-2.3.war init -d review_site</tt>
 
# Start gerrit with the new *.war file using the "init" flag. For example: <tt>cd /var/lib/gerrit2 && java -jar gerrit-2.3.war init -d review_site</tt>
 
# The updater is going to ask you some questions, keep the current values. When it asks you if you want to copy the *.war file to the bin directory, say ''yes''.
 
# The updater is going to ask you some questions, keep the current values. When it asks you if you want to copy the *.war file to the bin directory, say ''yes''.
 +
# Run puppet (this will restart gerrit)
 
# Profit!!
 
# Profit!!
  
 
''Note'': You may need to restart gerrit after the upgrade is finished.
 
''Note'': You may need to restart gerrit after the upgrade is finished.
  
== Custom package ==
+
== Getting the war ==
  
We maintain our own fork of Gerrit which is hosted ... in Gerrit! You will have to clone the operations/gerrit.git repository using the latest stable branch suffixed with -wmf:
+
We build Gerrit + our plugins from master daily with Jenkins (plus when Chad feels like it). These builds are available from [https://integration.mediawiki.org/nightly/gerrit/wmf/?C=M;O=D integration.mediawiki.org].
  
git clone https://gerrit.wikimedia.org/r/p/operations/gerrit -b stable-2.4-wmf
+
Generally speaking, the latest build is what we're running [https://gerrit-dev.wmflabs.org on labs]. This will be the case for production soon too (right now we're using a custom 2.4.2 build).
 
+
The branch is a fork of upstream <tt>stable-2.4</tt> with our custom patches piled on top.
+
 
+
To build the war (file will be in <tt>./gerrit-war/target</tt>)
+
mvn package -Dgerrit.include-documentation=1 -Dgwt.style=pretty
+
 
+
To replace the live version:
+
service gerrit stop
+
java -jar <custom war> init -d /var/lib/gerrit2/review_site --batch
+
service gerrit start
+
  
 
== Creating new repositories ==
 
== Creating new repositories ==
  
 
see [[mw:Git/Creating new repositories]]
 
see [[mw:Git/Creating new repositories]]
 +
 +
== Indexing ==
 +
We disabled indexing by search engines awhile back. Gitweb has awful performance, and the search engines were overloading manganese (mainly from requesting .tar urls from every commit they could dig for). We could possibly revisit this sometime in the future when we've got time to get actual stats (and we've [[bugzilla:38383|replaced Gitweb with Gitblit]]).
  
 
== See also ==
 
== See also ==
 
* [[gerrit-wm]]
 
* [[gerrit-wm]]
 
* [[gerrit.wikimedia.org]]
 
* [[gerrit.wikimedia.org]]

Latest revision as of 21:37, 11 February 2013

We use Gerrit for our code review system for Git. It supersedes the CodeReview extension.

Contents

[edit] Quick links

[edit] Details

Gerrit is installed on manganese in the prefix /var/lib/gerrit2. A slave instance runs on formey for fallover purposes.

It is a Java daemon which listens for HTTP connections (port 8080) and SSH connections (port 29418). Apache on manganese proxies the relevant URLs on port 80 and 443 through to Gerrit. The SSH port provides a restricted shell for Git checkouts and administrative commands.

It uses the misc DB server (db1048), database name "reviewdb", for most storage. Git repos are on NFS and stored at /var/lib/gerrit2/review_site/git.

It uses the LDAP instance shared with subversion and labs, possibly on virt0.wikimedia.org, for authentication. Accounts under ou=people,dc=wikimedia,dc=org and groups under ou=groups,dc=wikimedia,dc=org are exposed to Gerrit. The Gerrit account name is the "cn" field in LDAP. In order to log in to Gerrit, a user needs to already have a Labs account. See "Help:Access" on the Labsconsole wiki for the process of getting a Labs account.

Gerrit shells out to GitWeb, a Perl application which is installed using the stock package.

To find out what version of Gerrit is running, you can use either of the following two commands:

java -jar /var/lib/gerrit2/gerrit.war version
ssh -p 29418 gerrit.wikimedia.org gerrit version

It is 2.4.2-2-ge9a1970 at the time of writing.

[edit] Using git

This is documented on the labsconsole wiki and on mediawiki.org.

[edit] Database install

Database installation is handled by Gerrit installation process, you simply need a user named 'gerrit2' with appropriate privileges. Make sure to set the charset of the database to utf8.

Replace <PASSWORD> below and apply:

 CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY <PASSWORD>;
 CREATE DATABASE reviewdb;
 ALTER DATABASE reviewdb charset=utf8;
 GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
 FLUSH PRIVILEGES;


[edit] Upgrading Gerrit

  1. Back up the database (db1048.reviewdb) and git directories (/var/lib/gerrit2/review_site/git/). Just In Case.
  2. Download the latest .war file from Google Code to /var/lib/gerrit2/.
  3. Stop the gerrit daemon (/var/lib/gerrit2/review_site/bin/gerrit.sh stop)
  4. Start gerrit with the new *.war file using the "init" flag. For example: cd /var/lib/gerrit2 && java -jar gerrit-2.3.war init -d review_site
  5. The updater is going to ask you some questions, keep the current values. When it asks you if you want to copy the *.war file to the bin directory, say yes.
  6. Run puppet (this will restart gerrit)
  7. Profit!!

Note: You may need to restart gerrit after the upgrade is finished.

[edit] Getting the war

We build Gerrit + our plugins from master daily with Jenkins (plus when Chad feels like it). These builds are available from integration.mediawiki.org.

Generally speaking, the latest build is what we're running on labs. This will be the case for production soon too (right now we're using a custom 2.4.2 build).

[edit] Creating new repositories

see mw:Git/Creating new repositories

[edit] Indexing

We disabled indexing by search engines awhile back. Gitweb has awful performance, and the search engines were overloading manganese (mainly from requesting .tar urls from every commit they could dig for). We could possibly revisit this sometime in the future when we've got time to get actual stats (and we've replaced Gitweb with Gitblit).

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Ops documentation
Wiki
Toolbox