Install Gerrit 3.11.2 on Ubuntu 24.04

Introduction

This guide walks you through installing Gerrit 3.11.2 on Ubuntu 24.04, using Java 21 and a dedicated system user. The installation is done in development mode using the embedded Jetty server and H2 database, and Gerrit is managed with systemd as a background service.

Authentication is handled via Gerrit’s default development mode, allowing you to log in directly as admin with no password.


  1. Install Java 21
sudo apt update
sudo apt install openjdk-21-jdk -y

Verify:

java -version

You should see something like:

openjdk version "21" ...

  1. Create the gerrit System User
sudo groupadd --system --gid 2001 gerrit

sudo useradd --system --uid 2001 --gid 2001 \
  --home /home/gerrit \
  --shell /bin/bash \
  --create-home \
  gerrit

  1. Create the Gerrit Installation Directory
sudo mkdir -p /srv/gerrit
sudo chown gerrit:gerrit /srv/gerrit

  1. Download and Initialize Gerrit 3.11.2

Switch to the gerrit user:

sudo su - gerrit

Download the Gerrit WAR file:

wget https://gerrit-releases.storage.googleapis.com/gerrit-3.11.2.war -O gerrit.war

Initialize Gerrit:

java -jar gerrit.war init --batch --dev -d /srv/gerrit

Gerrit will be started automatically after initialization.

Exit the user shell:

exit

  1. Confirm Gerrit is Running

You can check that Gerrit is running with:

sudo -u gerrit /srv/gerrit/bin/gerrit.sh status

If needed, you can stop it with:

sudo -u gerrit /srv/gerrit/bin/gerrit.sh stop

  1. Configure Gerrit as a systemd Service

Create the service unit file:

sudo vi /etc/systemd/system/gerrit.service

Paste:

[Unit]
Description=Gerrit Code Review
After=network.target

[Service]
Type=forking
User=gerrit
ExecStart=/srv/gerrit/bin/gerrit.sh start
ExecStop=/srv/gerrit/bin/gerrit.sh stop
RemainAfterExit=yes
Restart=on-failure
OOMScoreAdjust=-1000

[Install]
WantedBy=multi-user.target

Enable and start Gerrit via systemd:

sudo systemctl daemon-reload
sudo systemctl enable --now gerrit

Verify it’s active:

sudo systemctl status gerrit

Expected:

Active: active (running)

  1. Access Gerrit Web UI

Open your browser and go to:

http://gerrit:8080

You’ll see a login screen. Under “Choose”, click on: “admin”, that logs you in as the default administrator (no password required in dev mode).

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top