blob: 0b06ffb9479896f68f5e87a4d64c1da57c8e0b36 [file] [log] [blame]
James E. Blaircdd00072012-06-08 19:17:28 -07001:title: Zuul
2
3Zuul
4====
5
6Configuration
7-------------
8
9Zuul has three configuration files:
10
11**zuul.conf**
12 Credentials for Gerrit and Jenkins, locations of the other config files
13**layout.yaml**
14 Project and queue configuration -- what Zuul does
15**logging.conf**
16 Python logging config
17
18Examples of each of the three files can be found in the etc/ directory
19of the source distribution.
20
21zuul.conf
22~~~~~~~~~
23
24Zuul will look for ``/etc/zuul/zuul.conf`` or ``~/zuul.conf`` to
25bootstrap its configuration. Alternately, you may specify ``-c
26/path/to/zuul.conf`` on the command line.
27
28Gerrit and Jenkins credentials are each described in a section of
29zuul.conf. The location of the other two configuration files (as well
30as the location of the PID file when running Zuul as a server) are
31specified in a third section.
32
33layout.yaml
34~~~~~~~~~~~
35
36This is the main configuration file for Zuul, where all of the queues
37and projects are defined, what tests should be run, and what actions
38Zuul should perform. There are three sections: queues, jobs, and
39projects.
40
41Queues
42""""""
43
44Zuul can have any number of independent queues. Whenever a matching
45Gerrit event is found for a queue, that event is added to the queue,
46and the jobs specified for that queue are run. When all jobs
47specified for the queue that were triggered by an event are completed,
48Zuul reports back to Gerrit the results.
49
50There are no pre-defined queues in Zuul, rather you can define
51whatever queues you need in the layout file. This is a very flexible
52system that can accommodate many kinds of workflows.
53
54Here is a quick example of a queue definition followed by an
55explanation of each of the parameters::
56
57 - name: check
58 manager: IndependentQueueManager
59 trigger:
60 - event: patchset-created
61 success:
62 verified: 1
63 failure:
64 verified: -1
65
66**name**
67 This is used later in the project definition to indicate what jobs
68 should be run for events in the queue.
69
70**manager**
71 There are currently two schemes for managing queues:
72
73 *IndependentQueueManager*
74 Every event in this queue should be treated as independent of
75 other events in the queue. This is appropriate when the order of
76 events in the queue doesn't matter because the results of the
77 actions this queue performs can not affect other events in the
78 queue. For example, when a change is first uploaded for review,
79 you may want to run tests on that change to provide early feedback
80 to reviewers. At the end of the tests, the change is not going to
81 be merged, so it is safe to run these tests in parallel without
82 regard to any other changes in the queue. They are independent.
83
84 Another type of queue that is independent is a post-merge queue.
85 In that case, the changes have already merged, so the results can
86 not affect any other events in the queue.
87
88 *DependentQueueManager*
89 The dependent queue manager is designed for gating. It ensures
90 that every change is tested exactly as it is going to be merged
91 into the repository. An ideal gating system would test one change
92 at a time, applied to the tip of the repository, and only if that
93 change passed tests would it be merged. Then the next change in
94 line would be tested the same way. In order to achieve parallel
95 testing of changes, the dependent queue manager performs
96 speculative execution on changes. It orders changes based on
97 their entry into the queue. It begins testing all changes in
98 parallel, assuming that each change ahead in the queue will pass
99 its tests. If they all succeed, all the changes can be tested and
100 merged in parallel. If a change near the front of the queue fails
101 its tests, each change behind it ignores whatever tests have been
102 completed and are tested again without the change in front. This
103 way gate tests may run in parallel but still be tested correctly,
104 exactly as they will appear in the repository when merged.
105
106 One important characteristic of the DependentQueueManager is that
107 it analyzes the jobs that are triggered by different projects, and
108 if those projects have jobs in common, it treats those projects as
109 related, and they share a single virtual queue of changes. Thus,
110 if there is a job that performs integration testing on two
111 projects, those two projects will automatically share a virtual
112 change queue. If a third project does not invoke that job, it
113 will be part of a separate virtual change queue, and changes to it
114 will not depend on changes to the first two jobs.
115
116 For more detail on the theory and operation of Zuul's
117 DependentQueueManager, see: :doc:`gating`.
118
119**trigger**
120 This describes what Gerrit events should be placed in the queue.
121 Triggers are not exclusive -- matching events may be placed in
122 multiple queues, and they will behave independently in each of the
123 queues they match. Multiple triggers may be listed. Further
124 parameters describe the kind of events that match:
125
126 *event*
127 The event name from gerrit. Examples: ``patchset-created``,
128 ``comment-added``, ``ref-updated``. This field is treated as a
129 regular expression.
130
131 *branch*
132 The branch associated with the event. Example: ``master``. This
133 field is treated as a regular expression, and multiple branches may
134 be listed.
135
136 *ref*
137 On ref-updated events, the branch parameter is not used, instead the
138 ref is provided. Currently Gerrit has the somewhat idiosyncratic
139 behavior of specifying bare refs for branch names (e.g., ``master``),
140 but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
141 Zuul matches what you put here exactly against what Gerrit
142 provides. This field is treated as a regular expression, and
143 multiple refs may be listed.
144
145 *approval*
146 This is only used for ``comment-added`` events. It only matches if
147 the event has a matching approval associated with it. Example:
148 ``code-review: 2`` matches a ``+2`` vote on the code review category.
149 Multiple approvals may be listed.
150
Clark Boylanb9bcb402012-06-29 17:44:05 -0700151 *comment_filter*
152 This is only used for ``comment-added`` events. It accepts a list of
153 regexes that are searched for in the comment string. If any of these
154 regexes matches a portion of the comment string the trigger is
155 matched. ``comment_filter: retrigger`` will match when comments
156 containing 'retrigger' somewhere in the comment text are added to a
157 change.
158
James E. Blaircdd00072012-06-08 19:17:28 -0700159**success**
160 Describes what Zuul should do if all the jobs complete successfully.
161 This section is optional; if it is omitted, Zuul will run jobs and
162 do nothing on success; it will not even report a message to Gerrit.
163 If the section is present, it will leave a message on the Gerrit
164 review. Each additional argument is assumed to be an argument to
165 ``gerrit review``, with the boolean value of ``true`` simply
166 indicating that the argument should be present without following it
167 with a value. For example, ``verified: 1`` becomes ``gerrit
168 review --verified 1`` and ``submit: true`` becomes ``gerrit review
169 --submit``.
170
171**failure**
172 Uses the same syntax as **success**, but describes what Zuul should
173 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700174
175**start**
176 Uses the same syntax as **success**, but describes what Zuul should
177 do when a change is added to the queue manager. This can be used,
178 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700179
180Some example queue configurations are included in the sample layout
181file. The first is called a *check* queue::
182
183 - name: check
184 manager: IndependentQueueManager
185 trigger:
186 - event: patchset-created
187 success:
188 verified: 1
189 failure:
190 verified: -1
191
192This will trigger jobs each time a new patchset (or change) is
193uploaded to Gerrit, and report +/-1 values to Gerrit in the
194``verified`` review category. ::
195
196 - name: gate
197 manager: DependentQueueManager
198 trigger:
199 - event: comment-added
200 approval:
201 - approved: 1
202 success:
203 verified: 2
204 submit: true
205 failure:
206 verified: -2
207
208This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
209``approved`` review category in Gerrit (a non-standard category).
210Changes will be tested in such a way as to guarantee that they will be
211merged exactly as tested, though that will happen in parallel by
212creating a virtual queue of dependent changes and performing
213speculative execution of jobs. ::
214
215 - name: post
216 manager: IndependentQueueManager
217 trigger:
218 - event: ref-updated
219 ref: ^(?!refs/).*$
220
221This will trigger jobs whenever a change is merged to a named branch
222(e.g., ``master``). No output will be reported to Gerrit. This is
223useful for side effects such as creating per-commit tarballs. ::
224
225 - name: silent
226 manager: IndependentQueueManager
227 trigger:
228 - event: patchset-created
229
230This also triggers jobs when changes are uploaded to Gerrit, but no
231results are reported to Gerrit. This is useful for jobs that are in
232development and not yet ready to be presented to developers.
233
234Jobs
235""""
236
237The jobs section is optional, and can be used to set attributes of
238jobs that are independent of their association with a project. For
239example, if a job should return a customized message on failure, that
240may be specified here. Otherwise, Zuul does not need to be told about
241each job as it builds a list from the project specification.
242
243**name**
244 The name of the job. This field is treated as a regular expression
245 and will be applied to each job that matches.
246
247**failure-message**
248 The message that should be reported to Gerrit if the job fails
249 (optional).
250
251**success-message**
252 The message that should be reported to Gerrit if the job fails
253 (optional).
254
255**branch**
256 This job should only be run on matching branches. This field is
257 treated as a regular expression and multiple branches may be
258 listed.
259
260Here is an example of setting the failure message for jobs that check
261whether a change merges cleanly::
262
263 - name: ^.*-merge$
264 failure-message: This change was unable to be automatically merged
265 with the current state of the repository. Please rebase your
266 change and upload a new patchset.
267
268Projects
269""""""""
270
271The projects section indicates what jobs should be run in each queue
272for events associated with each project. It contains a list of
273projects. Here is an example::
274
275 - name: example/project
276 check:
277 - project-merge:
278 - project-unittest
279 - project-pep8
280 - project-pyflakes
281 gate:
282 - project-merge:
283 - project-unittest
284 - project-pep8
285 - project-pyflakes
286 post:
287 - project-publish
288
289**name**
290 The name of the project (as known by Gerrit).
291
292This is followed by a section for each of the queues defined above.
293Queues may be omitted if no jobs should run for this project in a
294given queue. Within the queue section, the jobs that should be
295executed are listed. If a job is entered as a dictionary key, then
296jobs contained within that key are only executed if the key job
297succeeds. In the above example, project-unittest, project-pep8, and
298project-pyflakes are only executed if project-merge succeeds. This
299can help avoid running unnecessary jobs.
300
301.. seealso:: The OpenStack Zuul configuration for a comprehensive example: https://github.com/openstack/openstack-ci-puppet/blob/master/modules/openstack-ci-config/files/zuul/layout.yaml
302
303
304logging.conf
305~~~~~~~~~~~~
306This file is optional. If provided, it should be a standard
307:mod:`logging.config` module configuration file. If not present, Zuul will
308output all log messages of DEBUG level or higher to the console.
309
310Starting Zuul
311-------------
312
313To start Zuul, run **zuul-server**::
314
315 usage: zuul-server [-h] [-c CONFIG] [-d]
316
317 Project gating system.
318
319 optional arguments:
320 -h, --help show this help message and exit
321 -c CONFIG specify the config file
322 -d do not run as a daemon
323
324You may want to use the ``-d`` argument while you are initially setting
325up Zuul so you can detect any configuration errors quickly. Under
326normal operation, omit ``-d`` and let Zuul run as a daemon.
327
328If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
329stop executing new jobs, wait until all executing jobs are finished,
330reload its configuration, and resume. Any values in any of the
331configuration files may be changed, except the location of Zuul's PID
332file (a change to that will be ignored until Zuul is restarted).