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