22
Gerrit Code Review 2020-01-28

Gerrit Code Review - GitLab · 2020-01-28 · History The initial development of Gerrit started when a code review system for Android was requested. Because many Google developers

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

  • Gerrit Code Review2020-01-28

  • Table of ContentsHistory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2User documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2

    Standard method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2Dockerized method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2

    Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4Initialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4Verified status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  6Fast Forward / Rebase if necessary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7User preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  8Project creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  8

    Limit projects visibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  10Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  10Users groups creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11Projects creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  12

    Jenkins configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  14Plugin installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  14Plugin Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  14

    Code review golden rules (using Gerrit) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  17Quick start on client side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18

    Clone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18Commit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18

    Troobleshootings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19No pipeline triggered after configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19Submit replaced with Submit including parents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19Missing Change-Id in commit message footer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19My new script is not executable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  20

  • Table 1. History

    Date Author Detail

    2020-01-28 bcouetil Ὅ� (core) update theme

    2020-01-28 bcouetil Ὅ� (core) remove sample and build with docker

    2019-05-09 bcouetil eks terraform+ hyperledger + k8s aliases + cert manager + k8s aws anonymous+ k8s tools + gerrit replication

    2019-04-22 bcouetil eks dashboard & deployment scale + unselectable $ before shell commands +fully working spotlight

    2019-04-11 bcouetil k8s & aws-eks merge + k8s aws dashboard + k8s istio + jdk8 in CI + gitlab &nexus following lacroix exp + new backgrounds

    2019-03-01 bcouetil gerrit/jenkins doc updates from arkea installation

    2019-02-21 bcouetil EKS & Elastic update + Nginx highlight + Gerrit & Jenkins following Arkea usage+ oral technique following POEI

    2019-02-09 bcouetil new aws eks + gerrit groups + auto github synchro

    2019-01-23 bcouetil plugins slides + fragmented examples + text wrapping near images +screenshot-as-code + big-image + charts axis labels + plantuml remaining skins+ css fixes

    2018-12-18 bcouetil Moved Gerrit plugin configuration from Jenkins to Gerrit page + EnhancedHTML CSS + Cropped some images + Improved PlantUML skin

    2018-12-11 bcouetil - Added reveal plugins and background - Fixed reveal css following change instructure in asciidoc-reveal master (from previous version : 1.1.3) - ImplementedZenika layout in HTML and PDF - Reported back reveal-js enhancements

    2018-09-19 bcouetil - Sample asciidoctor maven project published on Github - Github & LinkedInlinks - Sample project tree - new images + resizing and positioning

    2018-08-29 bcouetil Asciidoc HTML look & feel changes

    2018-08-23 bcouetil Initial commit

    1

  • HistoryThe initial development of Gerrit started when a code review system for Android was requested. Becausemany Google developers were involved in the development of Android, the new system needed to have afeature set similar to the Google internal review system Mondrian. For this purpose, Rietveld was started.Because the development of Rietveld was not fast enough, Rietveld was forked and developed separately,then as Gerrit.

    The name originates from that of the Dutch architect Gerrit Rietveld.

    User documentationOfficial user documentation is here.

    InstallationStandard methodjava -jar gerrit.war init -d --install-all-plugins

    To configure replication to a Gitlab repo :

    • Create a replication.config file

    SITE_PATH/etc/replication.config

    [gerrit]  autoReload = true  replicateOnStartup = true[remote "gitlab"]  url = http://oauth2:[email protected]/${name}.git  push = +refs/tags/*:refs/tags/*  push = +refs/heads/*:refs/heads/*  rescheduleDelay = 15

    • (re)start the Gerrit server.

    Dockerized method

    With the openfrontier/gerrit image, you can start a ready-to-use dockerized server withpersistant data in a local folder, SMTP and replication configuration. Moreinformation/examples here.

    2

    https://gerrit-review.googlesource.com/Documentation/intro-user.htmlhttps://github.com/openfrontier/docker-gerrit

  • docker run -d --name gerrit-of -p 8080:8080 -p 29418:29418 \-e AUTH_TYPE=DEVELOPMENT_BECOME_ANY_ACCOUNT \-e WEBURL=http://my.public.url:8080 \-e SMTP_SERVER=my.smtp.server \-e USER_NAME="Gerrit CodeReview" \-e [email protected] \-v ~/gerrit_volume:/var/gerrit/review_site \-e GERRIT_INIT_ARGS="--install-plugin=analytics" \-e GERRIT_INIT_ARGS="--install-plugin=replication" \-e REPLICATION_REMOTES=gitlab \-e GITLAB_REMOTE=https://oauth2:[email protected]:MY_GROUP/\${name}.git \-e GITLAB_REPLICATE_ON_STARTUP=true \docker.io/openfrontier/gerrit

    Files

    Files are persisted, you can delete your container, and popup a new one, without loosing your files.

    If unmodified from the docker run command, they are stored in ~/gerrit_volume on current server.

    /etc/

    Configuration files are stored there. They are created and automatically populated and updated on dockerrun/start.

    [root@jks-gerrit-jenkins etc]# lsgerrit.config mail GerritSite.css replication.config GerritSiteFooter.html secure.config

    /logs/

    Log files are stored there. Tail replication_log at startup if it does not work as expected.

    [root@jks-gerrit-jeg nkins logs]# lsdelete_log gc_log httpd_log import_log replication_log sshd_log

    3

  • Configuration

    You can switch from new UI (PolyGerrit) to old UI with the link at the bottom of any page,and you can switch back to PolyGerrit by adding ?polygerrit=1 in the URL.

    Initialization

    Updated with new UI

    • Connect to Gerrit homepage

    ◦ First person to connect is the administrator

    ◦ Without LDAP, other users are added at first connection

    So, as the administrator :

    • Skip the plugin configuration

    • Click on the image in the top right corner → [Settings], and set

    Full name

    Changes per page = 100 rows

    Date/time format

    ☑ Set new changes to "work in progress"

    ▪ Click [Save changes]

    Ignore Whitespace = All

    ▪ Click [Save changes]

    New email address = [email protected]

    ▪ reload page

    ▪ select your mail in list

    ▪ delete [email protected]

    ▪ Click [Save changes]

    Click [Generate New Password]

    ▪ save it for later

    Permissions

    In further sections, actions are for old UI

    Jenkins technical user

    Without LDAP

    • Click on [People] → [List Groups] → [Non-interactive Users]

    • Add Jenkins' technical account in the list

    4

    mailto:[email protected]:[email protected]

  • Under LDAP

    If you use LDAP, and don’t have a technical user in it for Jenkins, you can create a local user using the SSH(or REST) API.

    Get or generate the Jenkins ssh public key, see Plugin Configuration.

     $ cat ~/.ssh/jenkins-server.id_rsa.pub | ssh -p 29418 [email protected] gerrit create-account --email [email protected] --group "'Non-Interactive Users'" --http-password my-jenkins-pwd --ssh-key - my-jenkins-user

    If you define the full name, you can’t define the login.

    If you want to add/change a parameter, use set-account :

     $ ssh -p 29418 [email protected] gerrit set-account --http-password my-jenkins-pwd my-jenkins-user

    Deleting tags

    • Click on [Projects] → [List] → [All-projects] → section [Access] → [Edit]

    • Under Reference: refs/tags/*

    ◦ Click on [Add Permission…] and select [Push]

    ◦ Select group [Administrator] and click [Force Push]

    ◦ Select group [Project Owners] and click [Force Push]

    ◦ Save Changes

    Now you can delete tags from your projects, for ex :

    git push --force --delete origin cg-wm-1.17.6

    Allow (gitweb) access for everyone

    • Click on [Projects] → [List] → [All-projects] → section [Access] → [Edit]

    • Under Reference: refs/meta/config

    ◦ Under Read

    ▪ Click on [Add Group]

    ▪ Enter Registered Users

    ▪ Click [Add]

    ▪ Save Changes

    5

  • Verified status

    Old UI

    • Click on [Projects] → [List] → [All-Projects] → section [General] → [Edit Config]

    • Add this

    [label "Verified"]  function = MaxWithBlock  value = -1 Fails  value = 0 No score  value = +1 Verified

    • Click on [Save], then [Close]

    • Click on [Publish Edit], then [Publish], [Code-Review+2], [Submit]

    • Click on [Projects] → [List] → [All-Projects] → [Access] → [Edit]

    • Under [Reference: refs/heads/*]

    ◦ Click on [Add Permission…] and select [Label Verified]

    ◦ Select group [Administrator]

    ◦ Select group [Non-Interactive Users]

    ◦ Select group [Project Owners]

    ◦ Save Changes

    6

  • PolyGerrit

    • Click on [BROWSE] → [Repositories] → [All-Projects] → section [Commands] → [EDITREPO CONFIG]

    • Add this

    [label "Verified"]  function = MaxWithBlock  value = -1 Fails  value = 0 No score  value = +1 Verified

    • Click on [SAVE], then [CLOSE]

    • Click on [START REVIEW] → [+2] → [START REVIEW] → [SUBMIT]

    Now we can add rights associated :

    PolyGerrit may not update itself right way. If Label Verified is absent, switch to Old UIat the bottom right of the page

    • Click on [BROWSE] → [REPOSITORIES] → [All-Projects] → [Access] → [Edit]

    • Under [Reference: refs/*]

    ◦ In Add group zone, select [Non-Interactive Users]

    ▪ This will add the group with *ALLOW permissions, else adjust it

    • Under [Reference: refs/heads/*]

    ◦ Click on Add Permission… select [Label Verified]

    ◦ Select group [Administrator]

    ◦ Select group [Non-Interactive Users]

    ◦ Save Changes

    Fast Forward / Rebase if necessaryBy default, when projet submissions are not fast forward, final submitting a change will create a mergecommit. The history is potentially doubled.

    • Click on [Projects] → [List] → [All-Projects] → [General]

    • Under [Submit Type], select [Rebase if Necessary]

    7

  • User preferencesClick on [YourName] → [Settings] → [Diff Preferences] and set columns = 120 (you willprobably have to paste it due to a GUI bug)

    Project creation

    Old UI

    Create your GIT project by clicking on [Projects] → [Create New Project]

    • Project Name = your-project-name

    • Rights Inherit From = All-Projects

    • Check that it has inherited correctly "Rebase if necessary", else change and save

    PolyGerrit

    Create your GIT project by clicking on [Browse] → [Repositories] → [Create New]

    • Repository Name = your-project-name

    • Rights Inherit From = All-Projects

    • Create initial empty commit = True

    • Click [Create]

    • Check that it has inherited correctly Rebase if necessary, else change and click [SAVE CHANGES]

    Project git address/URL

    To get the repo address of your project under Gerrit :

    • Navigate to [Projects] → [List]

    8

  • • in front of [your-project], click on (gitweb)

    • Take the .git text next to URL

    Example : https://my-url.com/gerrit/my-project.git

    If you don’t have access to Gitweb interface ("Not Found"), ask your admin to do Allow(gitweb) access for everyone.

    Users groups creation

    For each project, create a reviewer list and a validator list.

    • Go to [Projects] → [Create New Group]

    • Reviewers list

    ◦ Give a name, for example [dge-reviewers]

    ◦ Add every developers / primary reviewers on the project

    ◦ Click on [General]

    ◦ Description = Reviewers (+1)

    ◦ Click [Save Description]

    ◦ Check [Make group visible to all registered users]

    ◦ Click [Save Group Options]

    • Validators list

    ◦ Give a name for example [dge-validators]

    ◦ Add technical responsible and a backup

    ◦ Click on [General]

    ◦ Description = Validators (+2)

    ◦ Click [Save Description]

    9

    https://my-url.com/gerrit/my-project.git

  • ◦ check [Make group visible to all registered users]

    ◦ Click [Save Group Options]

    Figure 1. Repository without code review

    Limit projects visibility Updated with PolyGerrit UI

    Follow this section if you want to group projects, to let them be visible only by a user group, let’s say thebank section of an enterprise.

    Groups created in this section are not meant to replace reviewers and validators groups. People will bemembers of both segregations.

    ArchitectureFor bank-projects group, we create it below All-projects, and each bank project will inherit from it.

    10

  • Gerrit projects groups

    All-Projects

    bank-projects

    bank-project-1 bank-project-2

    The users will be divided in 2 groups : the bank-admins and the bank-devs.

    We don’t create a bank-users group, because there is no inheritence in user groups (and it would requireAdministrators to administer it, which imply more bottlenecks).

    Gerrit users groups

    All-Users

    Administrators

    Non-Interactive Users bank-admins

    bank-devs bank-robots

    adminadmin

    admin

    admin

    Users groups creation• Go to [Browse] → [Groups]

    ◦ Click on [CREATE NEW]

    ◦ Group name = bank-admins

    ◦ Click on [CREATE] and nothing to change

    • Click on [Groups]

    11

  • ◦ Click on [CREATE NEW]

    ◦ Group name = bank-devs

    ◦ Click on [CREATE]

    ◦ Change Owners = bank-admins

    ◦ Click on [CHANGE OWNERS]

    Now you can ask people to connect once, then add them in bank-admins or bank-devs if you areAdministrators or bank-admins.

    Projects creation

    Project group (parent)

    • Go to [Browse] → [Repositories]

    • Click on [CREATE NEW]

    ◦ Repository name = bank-projects

    ◦ Rights inherit from = All-Projects

    ◦ Owner = bank-admins

    ◦ Create initial empty commit = False

    ◦ Only serve as parent for other repositories = True

    ◦ Click [CREATE]

    • Change inherited options

    ◦ Description = Parent project for all BANK projects

    ◦ Submit type = Rebase if necessary

    ◦ Click [SAVE CHANGES]

    • Click on [Access] section → [Edit]

    ◦ For every Anonymous Users and Registered Users, set to DENY

    ◦ For every Registered Users, click [Add Group] add the ALLOW right to Administrators

    ◦ Click Save Changes

    We now change inherited rights :

    • Go to [Browse] → [Repositories] → [bank-projects] → [Commands] section → [EDITREPO CONFIG]

    • Replace content with :

    12

  • [access]  inheritFrom = All-Projects[submit]  action = rebase if necessary[access "refs/*"]  owner = group bank-admins  read = group bank-admins  read = group bank-devs[project]  description = Parent project for all BANK projects[access "refs/for/*"]  addPatchSet = group bank-admins  addPatchSet = group bank-devs[access "refs/for/refs/*"]  push = +force group bank-admins  push = +force group bank-devs[access "refs/heads/*"]  forgeAuthor = group bank-admins  forgeAuthor = group bank-devs  label-Code-Review = -1..+1 group bank-devs[access "refs/meta/config"]  read = group bank-admins  read = group bank-devs

    • Click on [SAVE], then [CLOSE]

    • Click on [START REVIEW] → [+2] → [START REVIEW] → btn:[SUBMIT

    Project (child)

    Create a project as you would do in Project creation but set :

    • Rights inherit from = bank-projects

    • Owner = bank-admins

    13

  • Jenkins configurationPlugin installation

    • Go to [Jenkins] → [Administration Jenkins] → [Gestion des plugins]

    • Install Gerrit Trigger

    Plugin Configuration• Create the console-master job if not already existing

    Create a new freestyle job.

    Name it console-master

    General

    ☑ [Restreindre où le projet peut être exécuté]

    ▪ master

    In [Build] → [Ajouter une étape au build] → [Exécuter un script shell] →paste this and save :

    ▪ first check if Jenkins has a key pair already generated

    ls -lart ~/.ssh/

    • if yes, generate the public key if none

    ssh-keygen does not like the ~

    ssh-keygen -y -f /home/jenkins/.ssh/id_rsa > /home/jenkins/.ssh/id_rsa.publs -lart ~/.ssh/more ~/.ssh/id_rsa.pub

    • if no, create the private/public keys

    ssh-keygen -t rsa -N "" -f "/home/jenkins/.ssh/id_rsa"ls -lart ~/.ssh/eval `ssh-agent -s`ssh-add ~/.ssh/id_rsamore ~/.ssh/id_rsa.pub

    • Add 1 executor on the master node (if none)

    ◦ [Home] → [État du lanceur de compilations] → [maître] → [Configurer]

    • Execute the console-master

    • Keep track of what the execution gave for later Gerrit configuration, example :

    14

  • ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQDKGER5oLwkNhcCYtTzmUQooA+1mdrjIGi84AVsOHyNpsMqFBhkpxfImvopvKlYiztXUA15dwwDsPWq1tUcy/4NWqKnMTQA57xxxT2r8suF/DVlH6fNn8T73mGz9+kT77FXHuaMfmDTqrwPngUYQMm2Y9kTjGhIcH/jseq6jCUawITAOs/6EUbs7jtJ/S+jMb6Ed60S7S/nR3IzQwVrXMiQjDdFsL8RWEBQ54T4cNia/HMI8MK7mEEF5K008g4Ru3Bidk+VSisPUYFPmNc/tE12RyAjvkcwWxrYqFEB5h6RlS0yWXAjCUzjv8T0ov4Wus+ZqNgqUMYtBBf+zQvQC1ub

    • When finished, remove the executor from master node (if none before)

    • Create a local trigger server

    ◦ [Home] → [Administrer Jenkins] → [Gerrit Trigger] → [Add New Server]

    ▪ Gerrit Connection Setting

    ▪ Name = local_server

    ▪ Hostname = your.gerrit.server

    ▪ Frontend URL = http://your.gerrit.server:8080/

    ▪ SSH Port = 29418

    ▪ Username = your-technical-user

    ▪ SSH Keyfile = /root/.ssh/id_rsa

    ▪ Gerrit Reporting Values

    ▪ Verify = , 1, -1, -1, -1

    ▪ Code Review = , 1, -1, -1, -1

    ◦ Click on [Advanced…]

    ◦ Gerrit Verified Commandes

    ▪ Started = vide

    ▪ Successful =

    gerrit review , --message 'Build Successful (◕‿◕) ' --verified

    ▪ Failed =

    gerrit review , --message 'Build Failed (ಠ_ಠ) ' --verified

    ▪ Unstable =

    gerrit review , --message 'Build Unstable ( ͠° ͟ʖ ͡°) ' --verified

    ▪ Not Built =

    gerrit review , --message 'No Builds Executed (╯︵╰,) ' --verified

    ◦ Save

    On Gerrit

    WARNING : This is if you have a LDAP server, else TODO put linux command

    15

    http://your.gerrit.server:8080/

  • • Connect with the technical user (svc-fr-bpmfact / Bpm-fact0ry)

    • Click on the user top right → [Settings] → [SSH Public Keys] → [Add Key…]

    • Add the public key content from Jenkins server (the one asked to be kept track earlier), starting withssh-rsa

    On Jenkins

    • Test the earlier configured connection of the trigger with [Test Connection] while editinglocal_server

    • Restart jenkins with : https://bpmfactory.s2-eu.nvx.com/jenkins/safeRestart

    • The Gerrit trigger should be up and running

    16

    https://bpmfactory.s2-eu.nvx.com/jenkins/safeRestart

  • Code review golden rules (using Gerrit)

    These are rules to be followed for a smooth overall development process :

    1. The team has to know that you are taking responsability of the current development task.

    2. If not sure of what to achieve, confirm with task responsible

    3. Target a complete realization in delays estimated by team leader. Alert on time shortage.

    4. Update documentation along with code whenever it’s needed.

    5. Do not group functionnalities in commit, to avoid long run reviews.

    a. It is possible to handle multiple review in parallel.

    6. Commit text has to be explicit, complete, and synthetic.

    a. Commit text must be one line for the sake of history and documentation readability (replace : with() and - with +). No limit to the lengh of the line.

    b. If the commit include documentation, set a first line commit text suitable for documentation. Putother information on other lines (they won’t appear in documentation history)

    7. Commit often, at least on tuesdays and thursdays (even on unfinished current task).

    8. No related changes should appear on the change in Gerrit, or you did not handle multiple reviewproperly.

    9. Fixing Jenkins failures is always a top priority.

    10. On Cannot merge Gerrit message, you have to pull/commit/push to rebase properly

    11. When Jenkins give a +1, add the reviewers list as reviewers, this should add all reviewing people.

    12. When added as a reviewer, try to give a review in the next half day, knowing that it blocks the process.

    a. You don’t have to be an expert to do a review. At least try to spot pieces of code not well explainedand missing javadoc. Try to imagine yourself as a future bug fixer who needs clean code to workproperly.

    17

  • b. If suitable, test the application or check the auto IT tests.

    c. If any, check that the generated documention looks good in PDF.

    d. Check that there is UT specifically testing the new/modified code.

    13. When at least 25% of the team gave a +1, add the validators list of reviewers for a final +2 reviewfollowed by a submit to the master branch.

    Quick start on client sideClone

    HTTP

    git clone http://:@:/.git

    • If you cloned without user/password, redefine origin :

    git remote set-url origin http://:@:/.git

    Commit• Ensure that you have the commit hook, see section Missing Change-Id in commit message footer

    • First commit

    git add .git commit

    • Amend commit

    git add .git commit --amend

    • Push to Gerrit

    git push origin HEAD:refs/for/master

    18

    http://:@:/.git

  • TroobleshootingsNo pipeline triggered after configurationYou might have no pipeline triggered after a first patchset pushed after configuration.

    We assume that you have :

    • tested connection of Gerrit plugin

    • checked that the Gerrit server in Jenkins has blue/green status

    • restarted Jenkins after Gerrit trigger configuration

    • Go to [Jenkins] → [Query and Trigger Gerrit Patches]

    ◦ Select Gerrit Server = local_server

    ◦ Query String = status:open

    ◦ Click [Search]

    If you have no result, you may have forgotten to give the appropriate rights to Non-Interactive Users inGerrit. After adjusting, click search again and you should see results right away by clicking [Search] again.

    Submit replaced with Submit including parentsIf the [Submit] button is replaced with [Submit including parents], there is obviously a problem inthe git tree. You have to rebase. You can ask the developer to do so in his IDE and push again. But you canalso do it in the UI :

    Click [Rebase], select

    ☑ Change parent revision

    leave the field blank

    Click [Rebase]

    Missing Change-Id in commit message footerOn your first push, you might get this error from Gerrit

     [f57ea8b] missing Change-Id in commit message footerProcessing changes: refs: 1Processing changes: refs: 1, doneERROR: [f57ea8b] missing Change-Id in commit message footer Hint: To automatically insert Change-Id, install the hook:  gitdir=$(git rev-parse --git-dir); scp -p -P 29418 [email protected]:hooks/commit-msg${gitdir}/hooks/ And then amend the commit:  git commit --amend

    Doing a [reset mixed] on the initial commit would solve the problem.

    If not, here is another solution :

    • Download this file https://gerrit-review.googlesource.com/tools/hooks/commit-msg

    19

    https://gerrit-review.googlesource.com/tools/hooks/commit-msg

  • • Put it in myproject/.git/hooks/

    • git commit --amend

    • Retry the push

    Last solution for unix (or Cygwin on Win7 or Ubuntu on Win10) :

    gitdir=$(git rev-parse --git-dir); wget -P ${gitdir}/hooks/ http://[email protected]/gerrit/tools/hooks/commit-msg && chmod +x ${gitdir}/hooks/commit-msg

    Figure 2. Peer review is better for ego than peer refactoring

    My new script is not executableWhen creating a new script file, for it to have right execution in the repository :

    • Create the file

    • Stage it

    • In command line

    git update-index --chmod=+x src/scripts/slavePrep.sh

    • Commit and push

    20

    Gerrit Code ReviewTable of ContentsHistoryUser documentationInstallationStandard methodDockerized method

    ConfigurationInitializationPermissionsVerified statusFast Forward / Rebase if necessaryUser preferencesProject creation

    Limit projects visibilityArchitectureUsers groups creationProjects creation

    Jenkins configurationPlugin installationPlugin Configuration

    Code review golden rules (using Gerrit)Quick start on client sideCloneCommit

    TroobleshootingsNo pipeline triggered after configurationSubmit replaced with Submit including parentsMissing Change-Id in commit message footerMy new script is not executable