blob: a56ab3cdd8a6211c8b1f172942e42fe839887255 [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**
Clark Boylan00635dc2012-09-19 14:03:08 -070014 Project and pipeline configuration -- what Zuul does
James E. Blaircdd00072012-06-08 19:17:28 -070015**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
Clark Boylan00635dc2012-09-19 14:03:08 -070036This is the main configuration file for Zuul, where all of the pipelines
James E. Blaircdd00072012-06-08 19:17:28 -070037and projects are defined, what tests should be run, and what actions
Clark Boylan00635dc2012-09-19 14:03:08 -070038Zuul should perform. There are three sections: pipelines, jobs, and
James E. Blaircdd00072012-06-08 19:17:28 -070039projects.
40
James E. Blaire5a847f2012-07-10 15:29:14 -070041.. _includes:
42
43Includes
44""""""""
45
46Custom functions to be used in Zuul's configuration may be provided
47using the ``includes`` directive. It accepts a list of files to
48include, and currently supports one type of inclusion, a python file::
49
50 includes:
51 - python-file: local_functions.py
52
53**python-file**
54 The path to a python file. The file will be loaded and objects that
55 it defines will be placed in a special environment which can be
56 referenced in the Zuul configuration. Currently only the
57 parameter-function attribute of a Job uses this feature.
58
Clark Boylan00635dc2012-09-19 14:03:08 -070059Pipelines
60"""""""""
James E. Blaircdd00072012-06-08 19:17:28 -070061
Clark Boylan00635dc2012-09-19 14:03:08 -070062Zuul can have any number of independent pipelines. Whenever a matching
63Gerrit event is found for a pipeline, that event is added to the
64pipeline, and the jobs specified for that pipeline are run. When all
65jobs specified for the pipeline that were triggered by an event are
66completed, Zuul reports back to Gerrit the results.
James E. Blaircdd00072012-06-08 19:17:28 -070067
Clark Boylan00635dc2012-09-19 14:03:08 -070068There are no pre-defined pipelines in Zuul, rather you can define
69whatever pipelines you need in the layout file. This is a very flexible
70system that can accommodate many kinds of workflows.
James E. Blaircdd00072012-06-08 19:17:28 -070071
Clark Boylan00635dc2012-09-19 14:03:08 -070072Here is a quick example of a pipeline definition followed by an
James E. Blaircdd00072012-06-08 19:17:28 -070073explanation of each of the parameters::
74
75 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -070076 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -070077 trigger:
78 - event: patchset-created
79 success:
80 verified: 1
81 failure:
82 verified: -1
83
84**name**
85 This is used later in the project definition to indicate what jobs
Clark Boylan00635dc2012-09-19 14:03:08 -070086 should be run for events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -070087
88**manager**
Clark Boylan00635dc2012-09-19 14:03:08 -070089 There are currently two schemes for managing pipelines:
James E. Blaircdd00072012-06-08 19:17:28 -070090
Clark Boylan00635dc2012-09-19 14:03:08 -070091 *IndependentPipelineManager*
92 Every event in this pipeline should be treated as independent of
93 other events in the pipeline. This is appropriate when the order of
94 events in the pipeline doesn't matter because the results of the
95 actions this pipeline performs can not affect other events in the
96 pipeline. For example, when a change is first uploaded for review,
James E. Blaircdd00072012-06-08 19:17:28 -070097 you may want to run tests on that change to provide early feedback
98 to reviewers. At the end of the tests, the change is not going to
99 be merged, so it is safe to run these tests in parallel without
Clark Boylan00635dc2012-09-19 14:03:08 -0700100 regard to any other changes in the pipeline. They are independent.
James E. Blaircdd00072012-06-08 19:17:28 -0700101
Clark Boylan00635dc2012-09-19 14:03:08 -0700102 Another type of pipeline that is independent is a post-merge
103 pipeline. In that case, the changes have already merged, so the
104 results can not affect any other events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700105
Clark Boylan00635dc2012-09-19 14:03:08 -0700106 *DependentPipelineManager*
107 The dependent pipeline manager is designed for gating. It ensures
James E. Blaircdd00072012-06-08 19:17:28 -0700108 that every change is tested exactly as it is going to be merged
109 into the repository. An ideal gating system would test one change
110 at a time, applied to the tip of the repository, and only if that
111 change passed tests would it be merged. Then the next change in
112 line would be tested the same way. In order to achieve parallel
Clark Boylan00635dc2012-09-19 14:03:08 -0700113 testing of changes, the dependent pipeline manager performs
James E. Blaircdd00072012-06-08 19:17:28 -0700114 speculative execution on changes. It orders changes based on
Clark Boylan00635dc2012-09-19 14:03:08 -0700115 their entry into the pipeline. It begins testing all changes in
116 parallel, assuming that each change ahead in the pipeline will pass
James E. Blaircdd00072012-06-08 19:17:28 -0700117 its tests. If they all succeed, all the changes can be tested and
Clark Boylan00635dc2012-09-19 14:03:08 -0700118 merged in parallel. If a change near the front of the pipeline
119 fails its tests, each change behind it ignores whatever tests have
120 been completed and are tested again without the change in front.
121 This way gate tests may run in parallel but still be tested
122 correctly, exactly as they will appear in the repository when
123 merged.
James E. Blaircdd00072012-06-08 19:17:28 -0700124
Clark Boylan00635dc2012-09-19 14:03:08 -0700125 One important characteristic of the DependentPipelineManager is that
James E. Blaircdd00072012-06-08 19:17:28 -0700126 it analyzes the jobs that are triggered by different projects, and
127 if those projects have jobs in common, it treats those projects as
128 related, and they share a single virtual queue of changes. Thus,
129 if there is a job that performs integration testing on two
130 projects, those two projects will automatically share a virtual
131 change queue. If a third project does not invoke that job, it
Clark Boylan00635dc2012-09-19 14:03:08 -0700132 will be part of a separate virtual change queue, and changes to
133 it will not depend on changes to the first two jobs.
James E. Blaircdd00072012-06-08 19:17:28 -0700134
135 For more detail on the theory and operation of Zuul's
Clark Boylan00635dc2012-09-19 14:03:08 -0700136 DependentPipelineManager, see: :doc:`gating`.
James E. Blaircdd00072012-06-08 19:17:28 -0700137
138**trigger**
Clark Boylan00635dc2012-09-19 14:03:08 -0700139 This describes what Gerrit events should be placed in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700140 Triggers are not exclusive -- matching events may be placed in
Clark Boylan00635dc2012-09-19 14:03:08 -0700141 multiple pipelines, and they will behave independently in each of the
142 pipelines they match. Multiple triggers may be listed. Further
James E. Blaircdd00072012-06-08 19:17:28 -0700143 parameters describe the kind of events that match:
144
145 *event*
146 The event name from gerrit. Examples: ``patchset-created``,
147 ``comment-added``, ``ref-updated``. This field is treated as a
148 regular expression.
149
150 *branch*
151 The branch associated with the event. Example: ``master``. This
152 field is treated as a regular expression, and multiple branches may
153 be listed.
154
155 *ref*
156 On ref-updated events, the branch parameter is not used, instead the
157 ref is provided. Currently Gerrit has the somewhat idiosyncratic
158 behavior of specifying bare refs for branch names (e.g., ``master``),
159 but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
160 Zuul matches what you put here exactly against what Gerrit
161 provides. This field is treated as a regular expression, and
162 multiple refs may be listed.
163
164 *approval*
165 This is only used for ``comment-added`` events. It only matches if
166 the event has a matching approval associated with it. Example:
167 ``code-review: 2`` matches a ``+2`` vote on the code review category.
168 Multiple approvals may be listed.
169
Clark Boylanb9bcb402012-06-29 17:44:05 -0700170 *comment_filter*
171 This is only used for ``comment-added`` events. It accepts a list of
172 regexes that are searched for in the comment string. If any of these
173 regexes matches a portion of the comment string the trigger is
174 matched. ``comment_filter: retrigger`` will match when comments
175 containing 'retrigger' somewhere in the comment text are added to a
176 change.
177
James E. Blaircdd00072012-06-08 19:17:28 -0700178**success**
179 Describes what Zuul should do if all the jobs complete successfully.
180 This section is optional; if it is omitted, Zuul will run jobs and
181 do nothing on success; it will not even report a message to Gerrit.
182 If the section is present, it will leave a message on the Gerrit
183 review. Each additional argument is assumed to be an argument to
184 ``gerrit review``, with the boolean value of ``true`` simply
185 indicating that the argument should be present without following it
186 with a value. For example, ``verified: 1`` becomes ``gerrit
187 review --verified 1`` and ``submit: true`` becomes ``gerrit review
188 --submit``.
189
190**failure**
191 Uses the same syntax as **success**, but describes what Zuul should
192 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700193
194**start**
195 Uses the same syntax as **success**, but describes what Zuul should
Clark Boylan00635dc2012-09-19 14:03:08 -0700196 do when a change is added to the pipeline manager. This can be used,
James E. Blairdc253862012-06-13 17:12:42 -0700197 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700198
Clark Boylan00635dc2012-09-19 14:03:08 -0700199Some example pipeline configurations are included in the sample layout
200file. The first is called a *check* pipeline::
James E. Blaircdd00072012-06-08 19:17:28 -0700201
202 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700203 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700204 trigger:
205 - event: patchset-created
206 success:
207 verified: 1
208 failure:
209 verified: -1
210
211This will trigger jobs each time a new patchset (or change) is
212uploaded to Gerrit, and report +/-1 values to Gerrit in the
213``verified`` review category. ::
214
215 - name: gate
Clark Boylan00635dc2012-09-19 14:03:08 -0700216 manager: DependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700217 trigger:
218 - event: comment-added
219 approval:
220 - approved: 1
221 success:
222 verified: 2
223 submit: true
224 failure:
225 verified: -2
226
227This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
228``approved`` review category in Gerrit (a non-standard category).
229Changes will be tested in such a way as to guarantee that they will be
230merged exactly as tested, though that will happen in parallel by
231creating a virtual queue of dependent changes and performing
232speculative execution of jobs. ::
233
234 - name: post
Clark Boylan00635dc2012-09-19 14:03:08 -0700235 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700236 trigger:
237 - event: ref-updated
238 ref: ^(?!refs/).*$
239
240This will trigger jobs whenever a change is merged to a named branch
241(e.g., ``master``). No output will be reported to Gerrit. This is
242useful for side effects such as creating per-commit tarballs. ::
243
244 - name: silent
Clark Boylan00635dc2012-09-19 14:03:08 -0700245 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700246 trigger:
247 - event: patchset-created
248
249This also triggers jobs when changes are uploaded to Gerrit, but no
250results are reported to Gerrit. This is useful for jobs that are in
251development and not yet ready to be presented to developers.
252
253Jobs
254""""
255
256The jobs section is optional, and can be used to set attributes of
257jobs that are independent of their association with a project. For
258example, if a job should return a customized message on failure, that
259may be specified here. Otherwise, Zuul does not need to be told about
260each job as it builds a list from the project specification.
261
262**name**
263 The name of the job. This field is treated as a regular expression
264 and will be applied to each job that matches.
265
James E. Blaire5a847f2012-07-10 15:29:14 -0700266**failure-message (optional)**
267 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700268
James E. Blaire5a847f2012-07-10 15:29:14 -0700269**success-message (optional)**
270 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700271
James E. Blair222d4982012-07-16 09:31:19 -0700272**hold-following-changes (optional)**
273 This is a boolean that indicates that changes that follow this
Clark Boylan00635dc2012-09-19 14:03:08 -0700274 change in a dependent change pipeline should wait until this job
James E. Blair222d4982012-07-16 09:31:19 -0700275 succeeds before launching. If this is applied to a very short job
276 that can predict whether longer jobs will fail early, this can be
277 used to reduce the number of jobs that Zuul will launch and
278 ultimately have to cancel. In that case, a small amount of
279 paralellization of jobs is traded for more efficient use of testing
280 resources. On the other hand, to apply this to a long running job
281 would largely defeat the parallelization of dependent change testing
282 that is the main feature of Zuul. The default is False.
283
James E. Blaire5a847f2012-07-10 15:29:14 -0700284**branch (optional)**
James E. Blaircdd00072012-06-08 19:17:28 -0700285 This job should only be run on matching branches. This field is
286 treated as a regular expression and multiple branches may be
287 listed.
288
James E. Blaire5a847f2012-07-10 15:29:14 -0700289**parameter-function (optional)**
290 Specifies a function that should be applied to the parameters before
291 the job is launched. The function should be defined in a python file
292 included with the :ref:`includes` directive. The function
293 should have the following signature:
294
295 .. function:: parameters(change, parameters)
296
297 Manipulate the parameters passed to a job before a build is
298 launched. The ``parameters`` dictionary will already contain the
299 standard Zuul job parameters, and is expected to be modified
300 in-place.
301
302 :param change: the current change
303 :type change: zuul.model.Change
304 :param parameters: parameters to be passed to the job
305 :type parameters: dict
306
James E. Blaircdd00072012-06-08 19:17:28 -0700307Here is an example of setting the failure message for jobs that check
308whether a change merges cleanly::
309
310 - name: ^.*-merge$
311 failure-message: This change was unable to be automatically merged
312 with the current state of the repository. Please rebase your
313 change and upload a new patchset.
314
315Projects
316""""""""
317
Clark Boylan00635dc2012-09-19 14:03:08 -0700318The projects section indicates what jobs should be run in each pipeline
James E. Blaircdd00072012-06-08 19:17:28 -0700319for events associated with each project. It contains a list of
320projects. Here is an example::
321
322 - name: example/project
323 check:
324 - project-merge:
325 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700326 - project-pep8
327 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700328 gate:
329 - project-merge:
330 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700331 - project-pep8
332 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700333 post:
334 - project-publish
335
336**name**
337 The name of the project (as known by Gerrit).
338
Clark Boylan00635dc2012-09-19 14:03:08 -0700339This is followed by a section for each of the pipelines defined above.
340Pipelines may be omitted if no jobs should run for this project in a
341given pipeline. Within the pipeline section, the jobs that should be
James E. Blaircdd00072012-06-08 19:17:28 -0700342executed are listed. If a job is entered as a dictionary key, then
343jobs contained within that key are only executed if the key job
344succeeds. In the above example, project-unittest, project-pep8, and
345project-pyflakes are only executed if project-merge succeeds. This
346can help avoid running unnecessary jobs.
347
Antoine Mussofec5c7a2012-09-22 12:32:37 +0200348.. seealso:: The OpenStack Zuul configuration for a comprehensive example: https://github.com/openstack/openstack-ci-puppet/blob/master/modules/openstack_project/files/zuul/layout.yaml
James E. Blaircdd00072012-06-08 19:17:28 -0700349
350
351logging.conf
352~~~~~~~~~~~~
353This file is optional. If provided, it should be a standard
354:mod:`logging.config` module configuration file. If not present, Zuul will
355output all log messages of DEBUG level or higher to the console.
356
357Starting Zuul
358-------------
359
360To start Zuul, run **zuul-server**::
361
362 usage: zuul-server [-h] [-c CONFIG] [-d]
363
364 Project gating system.
365
366 optional arguments:
367 -h, --help show this help message and exit
368 -c CONFIG specify the config file
369 -d do not run as a daemon
370
371You may want to use the ``-d`` argument while you are initially setting
372up Zuul so you can detect any configuration errors quickly. Under
373normal operation, omit ``-d`` and let Zuul run as a daemon.
374
375If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
376stop executing new jobs, wait until all executing jobs are finished,
377reload its configuration, and resume. Any values in any of the
378configuration files may be changed, except the location of Zuul's PID
379file (a change to that will be ignored until Zuul is restarted).