blob: d962edb3b96d59dbfd347cb80d08166917ba5454 [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
151**success**
152 Describes what Zuul should do if all the jobs complete successfully.
153 This section is optional; if it is omitted, Zuul will run jobs and
154 do nothing on success; it will not even report a message to Gerrit.
155 If the section is present, it will leave a message on the Gerrit
156 review. Each additional argument is assumed to be an argument to
157 ``gerrit review``, with the boolean value of ``true`` simply
158 indicating that the argument should be present without following it
159 with a value. For example, ``verified: 1`` becomes ``gerrit
160 review --verified 1`` and ``submit: true`` becomes ``gerrit review
161 --submit``.
162
163**failure**
164 Uses the same syntax as **success**, but describes what Zuul should
165 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700166
167**start**
168 Uses the same syntax as **success**, but describes what Zuul should
169 do when a change is added to the queue manager. This can be used,
170 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700171
172Some example queue configurations are included in the sample layout
173file. The first is called a *check* queue::
174
175 - name: check
176 manager: IndependentQueueManager
177 trigger:
178 - event: patchset-created
179 success:
180 verified: 1
181 failure:
182 verified: -1
183
184This will trigger jobs each time a new patchset (or change) is
185uploaded to Gerrit, and report +/-1 values to Gerrit in the
186``verified`` review category. ::
187
188 - name: gate
189 manager: DependentQueueManager
190 trigger:
191 - event: comment-added
192 approval:
193 - approved: 1
194 success:
195 verified: 2
196 submit: true
197 failure:
198 verified: -2
199
200This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
201``approved`` review category in Gerrit (a non-standard category).
202Changes will be tested in such a way as to guarantee that they will be
203merged exactly as tested, though that will happen in parallel by
204creating a virtual queue of dependent changes and performing
205speculative execution of jobs. ::
206
207 - name: post
208 manager: IndependentQueueManager
209 trigger:
210 - event: ref-updated
211 ref: ^(?!refs/).*$
212
213This will trigger jobs whenever a change is merged to a named branch
214(e.g., ``master``). No output will be reported to Gerrit. This is
215useful for side effects such as creating per-commit tarballs. ::
216
217 - name: silent
218 manager: IndependentQueueManager
219 trigger:
220 - event: patchset-created
221
222This also triggers jobs when changes are uploaded to Gerrit, but no
223results are reported to Gerrit. This is useful for jobs that are in
224development and not yet ready to be presented to developers.
225
226Jobs
227""""
228
229The jobs section is optional, and can be used to set attributes of
230jobs that are independent of their association with a project. For
231example, if a job should return a customized message on failure, that
232may be specified here. Otherwise, Zuul does not need to be told about
233each job as it builds a list from the project specification.
234
235**name**
236 The name of the job. This field is treated as a regular expression
237 and will be applied to each job that matches.
238
239**failure-message**
240 The message that should be reported to Gerrit if the job fails
241 (optional).
242
243**success-message**
244 The message that should be reported to Gerrit if the job fails
245 (optional).
246
247**branch**
248 This job should only be run on matching branches. This field is
249 treated as a regular expression and multiple branches may be
250 listed.
251
252Here is an example of setting the failure message for jobs that check
253whether a change merges cleanly::
254
255 - name: ^.*-merge$
256 failure-message: This change was unable to be automatically merged
257 with the current state of the repository. Please rebase your
258 change and upload a new patchset.
259
260Projects
261""""""""
262
263The projects section indicates what jobs should be run in each queue
264for events associated with each project. It contains a list of
265projects. Here is an example::
266
267 - name: example/project
268 check:
269 - project-merge:
270 - project-unittest
271 - project-pep8
272 - project-pyflakes
273 gate:
274 - project-merge:
275 - project-unittest
276 - project-pep8
277 - project-pyflakes
278 post:
279 - project-publish
280
281**name**
282 The name of the project (as known by Gerrit).
283
284This is followed by a section for each of the queues defined above.
285Queues may be omitted if no jobs should run for this project in a
286given queue. Within the queue section, the jobs that should be
287executed are listed. If a job is entered as a dictionary key, then
288jobs contained within that key are only executed if the key job
289succeeds. In the above example, project-unittest, project-pep8, and
290project-pyflakes are only executed if project-merge succeeds. This
291can help avoid running unnecessary jobs.
292
293.. 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
294
295
296logging.conf
297~~~~~~~~~~~~
298This file is optional. If provided, it should be a standard
299:mod:`logging.config` module configuration file. If not present, Zuul will
300output all log messages of DEBUG level or higher to the console.
301
302Starting Zuul
303-------------
304
305To start Zuul, run **zuul-server**::
306
307 usage: zuul-server [-h] [-c CONFIG] [-d]
308
309 Project gating system.
310
311 optional arguments:
312 -h, --help show this help message and exit
313 -c CONFIG specify the config file
314 -d do not run as a daemon
315
316You may want to use the ``-d`` argument while you are initially setting
317up Zuul so you can detect any configuration errors quickly. Under
318normal operation, omit ``-d`` and let Zuul run as a daemon.
319
320If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
321stop executing new jobs, wait until all executing jobs are finished,
322reload its configuration, and resume. Any values in any of the
323configuration files may be changed, except the location of Zuul's PID
324file (a change to that will be ignored until Zuul is restarted).