DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Integrating Jenkins With Playwright TypeScript: A Complete Guide
  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Beyond Jenkins: The Power of Cloud-Native AWS CodePipeline for Deployments
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?

Trending

  • Agile and Quality Engineering: A Holistic Perspective
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 1
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • Beyond Simple Responses: Building Truly Conversational LLM Chatbots
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Gerrit (Code Review), GitLab (Replication) Jenkins Integration

Gerrit (Code Review), GitLab (Replication) Jenkins Integration

Explore a tutorial of integrating Gerrit and Gitlab.

By 
Ganesh babu user avatar
Ganesh babu
·
Updated Nov. 16, 18 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
23.3K Views

Join the DZone community and get the full member experience.

Join For Free

Upcoming DevOps culture needs the end to end traceability and work done by the automation so when it comes to the code review part, it's still a starting phase of implementation found everywhere.

So, I started exploring how to do the code review from the developer point of view using Gerrit and replicate the same repository to the Gitlab and status events triggers can be shown in Jenkins.

The following are the requirements for the Gerrit installation:

1) Linux Node — I suggest Centos 7

2) Java package 1.8

3) MySQL MariaDB

4) Gerrit stable and latest release packgae from the gerrit mirror.

Installation process

Yum update -y
yum install java-1.8.0-openjdk.x86_64 -y
java -version
Yum install mariadb mariadb-server mysql
systemctl restart mariadb
systemctl status mariadb
systemctl enable mariadb

Once the Mysql service is started succcessfully. Change the root password for root login

mysql_secure_installation
Enter current password for root (enter for none): ENTER
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Installing Gerrit and creating a database for gerrit with granting all privileges to the database.

mysql -u root -p
MariaDB> create database gerritdb;
MariaDB> grant all on gerritdb.* to gerrit@localhost identified by 'secret';

Add gerrit user on Centos node to install the gerrit configuration package.

Wget https://gerrit-releases.storage.googleapis.com/gerrit-2.15.5.war

Once the latest version of war is downloaded, extract the war files as follows:

java -jar gerrit.war init -d /home/gerrit/gerrit-2.15

During the installation, the wizard may ask some default options to choose for the requirements based.

Location of Git repositories   [git]: GIT
Database server type           [mysql]: Mysql
Server hostname                [localhost]: Enter
Server port                    [(mysql default)]:Enter 
Database name                  [gerritdb]: Enter
Database username              [gerrit]: Enter
Change gerrit's password       [y/N]? : Enter
Type                           [LUCENE/?]: Enter
Authentication method          [HTTP/?]: ? (Use Devlopment option)
Get username from custom HTTP header [y/N]?  Enter
SSO logout URL                 : Enter
Install Verified label         [y/N]? Enter
SMTP server hostname           [localhost]: Enter
SMTP server port               [(default)]: Enter
SMTP encryption                [NONE/?]: Enter
SMTP username                  : Enter
Run as                         [gerrit]: Enter
Java runtime                   [/usr/java/jdk1.8.0_25/jre]: Enter
Upgrade /home/gerrit2/review_site/bin/gerrit.war [Y/n]? : Y
Copying gerrit.war to /home/gerrit2/review_site/bin/gerrit.war
Listen on address              [*]: Enter
Listen on port                 [29418]: Enter
Behind reverse proxy           [Y/n]? Enter
Proxy uses SSL (https://)      [y/N]? Enter
Subdirectory on proxy server   [/gerrit/]: Enter
Listen on address              [*]: Enter
Listen on port                 [8081]: Enter
Canonical URL                  [http://ganeshbabu.com/gerrit/]: Enter (if you want change the external url you can do it here
Install plugin commit-message-length-validator version v2.9.1 [y/N]? Y
Install plugin download-commands version v2.9.1 [y/N]? Y
Install plugin replication version v2.9.1 [y/N]? Y
Install plugin reviewnotes version v2.9.1 [y/N]? Y
Install plugin singleusergroup version v2.9.1 [y/N]? Y

Once the installation is done, Start the Gerrit service with the below command

Sh /home/gerrit/gerrit-2.15/bin/gerrit.sh start -- stop -- restart

Now go to gerrit Dashboard http://xx.xx.xx.xx:8080

1) Create a user as admin or administrator

Image title

2) Create a Project repository

Image title

3) Clone it into the local machine with hook commit msg

Image title

Image title

4) Do the code changes on the repository branch, and commit and push it to accordingly.

Now, you can go to Gitlab Dashboard and Create a User for Gerrit, or you can use the admin account for the integration of Gerrit with Gitlab for the replication.

5) Y you need to create a replication.config on Gerrit node.

Vim /home/gerrit/etc/replication.config

Image title

a) Project Name should be same as in Gerrit and Gitlab

b) Git repository Url should be mentioned on the replication.config

c) If everything goes fine, you can see the logs under /home/gerrit/logs/replication.log as success.

Image title

Once the replication is started, the code changes can be imported to Gitlab.

So, when it comes to Jenkins integration with Gerrit, it makes sense for complete phase of the solution.

We have many blogs and references for Jenkins to install and configure its basic setup, so I am skipping it here.

Once the installation of Jenkins and Gerrit. We need to install plugins for Gerrit to integrate it with lot many tools like Jenkins, Jira, etc.

Below are the steps and commands to install the plugins on Gerrit.

This is the Gerrit plugins mirror URL. we can find out many plugins based on versions and tools.

https://gerrit-ci.gerritforge.com/view/Plugins-stable-2.14/job/plugin-reviewers-bazel-stable-2.14/lastSuccessfulBuild/artifact/bazel-genfiles/plugins/reviewers/reviewers.jar

ssh -p 29418 admin@gerritserverip gerrit plugin install -n reviewers-review.jar https://gerrit-ci.gerritforge.com/view/Plugins-stable-2.14/job/plugin-reviewers-bazel-stable-2.14/lastSuccessfulBuild/artifact/bazel-genfiles/plugins/reviewers/reviewers.jar

Once the plugin is installed, it can be intracted with defined tools.

Now, we can see the Jenkins Gerrit integration configuration.

So, after installing the Gerrit plugin on Jenkins, manage plugin tab --> go to manage jenkins --> Gerrit icon. and do the below configuration changes.

Image title


And also, we need to enable the API authentication between Jenkins and Gerrit for the automatic build trigger when the user does his changes on the Gerrit server, it will build automatically on Jenkins.

Image title

Make sure it's the same user and password created on Gerrit account DB.

Finally, we come to the end of the integration part of Jenkins and Gerrit.

There are different sets of triggers in the Gerrit use case of Jenkins, so use it accordingly for the best results.

Gerrit (software) Jenkins (software) GitLab Integration Replication (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Integrating Jenkins With Playwright TypeScript: A Complete Guide
  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Beyond Jenkins: The Power of Cloud-Native AWS CodePipeline for Deployments
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!