Jump to content

Gerrit/Bot account

From Wikitech

A bot account is a user account reporting to Gerrit without human interactions, in Gerrit such accounts are referred to as being a service user. A typical example is the Zuul/Jenkins CI reporting as jenkins-bot. This page has a few guidelines for those accounts.

The account MUST be added to the Gerrit "Service Users" group which is a built-in group. Members of the group have a few behaviors adjusted:

Review comments send by bot accounts should add to their review a tag prefixed with autogenerated: which will filter older messages from the Web UI. Tags are free form, they can be used to differentiate between messages emitted by the bot, for example Zuul CI adds the pipeline (test, gate-and-submit) which triggered the message, respectively: tag: autogenerated:ci-test and tag: autogenerated:gate-and-submit.

Checks UI

Message emitted by the bots can be integrated in the Checks web ui by using the JavaScript Plugin Checks API. This requires JavaScript code to be added to our Gerrit deployment repository (https://gerrit.wikimedia.org/g/operations/software/gerrit/ , branch deploy/wmf/stable-X.Y, file plugins/wm-checks-api.js). As of March 2023 and Gerrit 3.5 the file is https://gerrit.wikimedia.org/g/operations/software/gerrit/+/refs/heads/deploy/wmf/stable-3.5/plugins/wm-checks-api.js

Each message in Gerrit is a ChangeMessageInfo, the TypeScript API for Gerrit version 3.5 can be read at https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/gerrit/+/refs/heads/stable-3.5/polygerrit-ui/app/api/rest-api.ts#434

/**
 * The ChangeMessageInfo entity contains information about a message attached
 * to a change.
 * https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-message-info
 */
export declare interface ChangeMessageInfo {
  id: ChangeMessageId;
  author?: AccountInfo;
  reviewer?: AccountInfo;
  updated_by?: AccountInfo;
  real_author?: AccountInfo;
  date: Timestamp;
  message: string;
  accounts_in_message?: AccountInfo[];
  tag?: ReviewInputTag;
  _revision_number?: PatchSetNum;
}

The Checks API has a TypeScript definition is at https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/app/api/checks.ts ).

Additions should be requested via a task to Phabricator against the #gerrit tag with a subject prefixed by [wm-checks-api].

References