blob: 6cd2f3d33b8eb0e219da35f9ad89ac6abfbb2edd [file] [log] [blame]
James E. Blaireff5a9d2017-06-20 00:00:37 -07001:title: Gerrit Driver
2
3Gerrit
4======
5
6`Gerrit`_ is a code review system. The Gerrit driver supports
7sources, triggers, and reporters.
8
9.. _Gerrit: https://www.gerritcodereview.com/
10
11Zuul will need access to a Gerrit user.
12
13Create an SSH keypair for Zuul to use if there isn't one already, and
14create a Gerrit user with that key::
15
16 cat ~/id_rsa.pub | ssh -p29418 review.example.com gerrit create-account --ssh-key - --full-name Zuul zuul
17
18Give that user whatever permissions will be needed on the projects you
19want Zuul to report on. For instance, you may want to grant
20``Verified +/-1`` and ``Submit`` to the user. Additional categories
21or values may be added to Gerrit. Zuul is very flexible and can take
22advantage of those.
23
24Connection Configuration
25------------------------
26
27The supported options in zuul.conf connections are:
28
29**driver=gerrit**
30
31**server**
32 FQDN of Gerrit server.
33 ``server=review.example.com``
34
35**canonical_hostname**
36 The canonical hostname associated with the git repos on the Gerrit
37 server. Defaults to the value of **server**. This is used to
38 identify repos from this connection by name and in preparing repos
39 on the filesystem for use by jobs.
40 ``canonical_hostname=git.example.com``
41
42**port**
43 Optional: Gerrit server port.
44 ``port=29418``
45
46**baseurl**
47 Optional: path to Gerrit web interface. Defaults to ``https://<value
48 of server>/``. ``baseurl=https://review.example.com/review_site/``
49
50**user**
51 User name to use when logging into above server via ssh.
52 ``user=zuul``
53
54**sshkey**
55 Path to SSH key to use when logging into above server.
56 ``sshkey=/home/zuul/.ssh/id_rsa``
57
58**keepalive**
59 Optional: Keepalive timeout, 0 means no keepalive.
60 ``keepalive=60``
61
62Trigger Configuration
63---------------------
64
65Zuul works with standard versions of Gerrit by invoking the ``gerrit
66stream-events`` command over an SSH connection. It also reports back
67to Gerrit using SSH.
68
69If using Gerrit 2.7 or later, make sure the user is a member of a group
70that is granted the ``Stream Events`` permission, otherwise it will not
71be able to invoke the ``gerrit stream-events`` command over SSH.
72
73The supported pipeline trigger options are:
74
75**event**
76The event name from gerrit. Examples: ``patchset-created``,
77``comment-added``, ``ref-updated``. This field is treated as a
78regular expression.
79
80**branch**
81The branch associated with the event. Example: ``master``. This
82field is treated as a regular expression, and multiple branches may
83be listed.
84
85**ref**
86On ref-updated events, the branch parameter is not used, instead the
87ref is provided. Currently Gerrit has the somewhat idiosyncratic
88behavior of specifying bare refs for branch names (e.g., ``master``),
89but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
90Zuul matches what you put here exactly against what Gerrit
91provides. This field is treated as a regular expression, and
92multiple refs may be listed.
93
94**ignore-deletes**
95When a branch is deleted, a ref-updated event is emitted with a newrev
96of all zeros specified. The ``ignore-deletes`` field is a boolean value
97that describes whether or not these newrevs trigger ref-updated events.
98The default is True, which will not trigger ref-updated events.
99
100**approval**
101This is only used for ``comment-added`` events. It only matches if
102the event has a matching approval associated with it. Example:
103``code-review: 2`` matches a ``+2`` vote on the code review category.
104Multiple approvals may be listed.
105
106**email**
107This is used for any event. It takes a regex applied on the performer
108email, i.e. Gerrit account email address. If you want to specify
109several email filters, you must use a YAML list. Make sure to use non
110greedy matchers and to escapes dots!
111Example: ``email: ^.*?@example\.org$``.
112
113**email_filter** (deprecated)
114A deprecated alternate spelling of *email*. Only one of *email* or
115*email_filter* should be used.
116
117**username**
118This is used for any event. It takes a regex applied on the performer
119username, i.e. Gerrit account name. If you want to specify several
120username filters, you must use a YAML list. Make sure to use non greedy
121matchers and to escapes dots!
122Example: ``username: ^jenkins$``.
123
124**username_filter** (deprecated)
125A deprecated alternate spelling of *username*. Only one of *username* or
126*username_filter* should be used.
127
128**comment**
129This is only used for ``comment-added`` events. It accepts a list of
130regexes that are searched for in the comment string. If any of these
131regexes matches a portion of the comment string the trigger is
132matched. ``comment: retrigger`` will match when comments
133containing 'retrigger' somewhere in the comment text are added to a
134change.
135
136**comment_filter** (deprecated)
137A deprecated alternate spelling of *comment*. Only one of *comment* or
138*comment_filter* should be used.
139
140*require-approval*
141This may be used for any event. It requires that a certain kind
142of approval be present for the current patchset of the change (the
143approval could be added by the event in question). It follows the
144same syntax as the :ref:`"approval" pipeline requirement
145<pipeline-require-approval>`. For each specified criteria there must
146exist a matching approval.
147
148*reject-approval*
149This takes a list of approvals in the same format as
150*require-approval* but will fail to enter the pipeline if there is
151a matching approval.
152
153Reporter Configuration
154----------------------
155
156Zuul works with standard versions of Gerrit by invoking the
157``gerrit`` command over an SSH connection. It reports back to
158Gerrit using SSH.
159
160The dictionary passed to the Gerrit reporter is used for ``gerrit
161review`` arguments, with the boolean value of ``true`` simply
162indicating that the argument should be present without following it
163with a value. For example, ``verified: 1`` becomes ``gerrit review
164--verified 1`` and ``submit: true`` becomes ``gerrit review
165--submit``.
166
167A :ref:`connection<connections>` that uses the gerrit driver must be
168supplied to the trigger.