blob: 92b7a6fa80cb44a7a4a2042a42e79e4b3ad7c854 [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
Clark Boylan9b670902012-09-28 13:47:56 -070033The three sections of this config and their options are documented below.
34You can also find an example zuul.conf file in the git
35`repository
36<https://github.com/openstack-ci/zuul/blob/master/etc/zuul.conf-sample>`_
37
38jenkins
39"""""""
40
41**server**
42 URL for the root of the Jenkins HTTP server.
43 ``server=https://jenkins.example.com``
44
45**user**
46 User to authenticate against Jenkins with.
47 ``user=jenkins``
48
49**apikey**
50 Jenkins API Key credentials for the above user.
51 ``apikey=1234567890abcdef1234567890abcdef``
52
53gerrit
54""""""
55
56**server**
57 FQDN of Gerrit server.
58 ``server=review.example.com``
59
Antoine Musso27475012012-11-26 09:53:01 +010060**baseurl**
61 Optional: path to Gerrit web interface. Defaults to ``https://<value
62 of server>/``. ``baseurl=https://review.example.com/review_site/``
63
Clark Boylan9b670902012-09-28 13:47:56 -070064**user**
65 User name to use when logging into above server via ssh.
66 ``user=jenkins``
67
68**sshkey**
69 Path to SSH key to use when logging into above server.
70 ``sshkey=/home/jenkins/.ssh/id_rsa``
71
72zuul
73""""
74
75**layout_config**
76 Path to layout config file.
77 ``layout_config=/etc/zuul/layout.yaml``
78
79**log_config**
80 Path to log config file.
81 ``log_config=/etc/zuul/logging.yaml``
82
83**pidfile**
84 Path to PID lock file.
85 ``pidfile=/var/run/zuul/zuul.pid``
86
87**state_dir**
88 Path to directory that Zuul should save state to.
89 ``state_dir=/var/lib/zuul``
90
91**git_dir**
92 Directory that Zuul should clone local git repositories to.
93 ``git_dir=/var/lib/zuul/git``
94
95**push_change_refs**
96 Boolean value (``true`` or ``false``) that determines if Zuul should
97 push change refs to the git origin server for the git repositories in
98 git_dir.
99 ``push_change_refs=true``
100
101**status_url**
102 URL that will be posted in Zuul comments made to Gerrit changes when
103 beginning Jenkins jobs for a change.
104 ``status_url=https://jenkins.example.com/zuul/status``
105
106**url_pattern**
107 If you are storing build logs external to Jenkins and wish to link to
108 those logs when Zuul makes comments on Gerrit changes for completed
109 jobs this setting configures what the URLs for those links should be.
110 ``http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number}``
111
James E. Blaircdd00072012-06-08 19:17:28 -0700112layout.yaml
113~~~~~~~~~~~
114
Clark Boylan00635dc2012-09-19 14:03:08 -0700115This is the main configuration file for Zuul, where all of the pipelines
James E. Blaircdd00072012-06-08 19:17:28 -0700116and projects are defined, what tests should be run, and what actions
Clark Boylan00635dc2012-09-19 14:03:08 -0700117Zuul should perform. There are three sections: pipelines, jobs, and
James E. Blaircdd00072012-06-08 19:17:28 -0700118projects.
119
James E. Blaire5a847f2012-07-10 15:29:14 -0700120.. _includes:
121
122Includes
123""""""""
124
125Custom functions to be used in Zuul's configuration may be provided
126using the ``includes`` directive. It accepts a list of files to
127include, and currently supports one type of inclusion, a python file::
128
129 includes:
130 - python-file: local_functions.py
131
132**python-file**
133 The path to a python file. The file will be loaded and objects that
134 it defines will be placed in a special environment which can be
135 referenced in the Zuul configuration. Currently only the
136 parameter-function attribute of a Job uses this feature.
137
Clark Boylan00635dc2012-09-19 14:03:08 -0700138Pipelines
139"""""""""
James E. Blaircdd00072012-06-08 19:17:28 -0700140
Clark Boylan00635dc2012-09-19 14:03:08 -0700141Zuul can have any number of independent pipelines. Whenever a matching
142Gerrit event is found for a pipeline, that event is added to the
143pipeline, and the jobs specified for that pipeline are run. When all
144jobs specified for the pipeline that were triggered by an event are
145completed, Zuul reports back to Gerrit the results.
James E. Blaircdd00072012-06-08 19:17:28 -0700146
Clark Boylan00635dc2012-09-19 14:03:08 -0700147There are no pre-defined pipelines in Zuul, rather you can define
148whatever pipelines you need in the layout file. This is a very flexible
149system that can accommodate many kinds of workflows.
James E. Blaircdd00072012-06-08 19:17:28 -0700150
Clark Boylan00635dc2012-09-19 14:03:08 -0700151Here is a quick example of a pipeline definition followed by an
James E. Blaircdd00072012-06-08 19:17:28 -0700152explanation of each of the parameters::
153
154 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700155 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700156 trigger:
157 - event: patchset-created
158 success:
159 verified: 1
160 failure:
161 verified: -1
162
163**name**
164 This is used later in the project definition to indicate what jobs
Clark Boylan00635dc2012-09-19 14:03:08 -0700165 should be run for events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700166
167**manager**
Clark Boylan00635dc2012-09-19 14:03:08 -0700168 There are currently two schemes for managing pipelines:
James E. Blaircdd00072012-06-08 19:17:28 -0700169
Clark Boylan00635dc2012-09-19 14:03:08 -0700170 *IndependentPipelineManager*
171 Every event in this pipeline should be treated as independent of
172 other events in the pipeline. This is appropriate when the order of
173 events in the pipeline doesn't matter because the results of the
174 actions this pipeline performs can not affect other events in the
175 pipeline. For example, when a change is first uploaded for review,
James E. Blaircdd00072012-06-08 19:17:28 -0700176 you may want to run tests on that change to provide early feedback
177 to reviewers. At the end of the tests, the change is not going to
178 be merged, so it is safe to run these tests in parallel without
Clark Boylan00635dc2012-09-19 14:03:08 -0700179 regard to any other changes in the pipeline. They are independent.
James E. Blaircdd00072012-06-08 19:17:28 -0700180
Clark Boylan00635dc2012-09-19 14:03:08 -0700181 Another type of pipeline that is independent is a post-merge
182 pipeline. In that case, the changes have already merged, so the
183 results can not affect any other events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700184
Clark Boylan00635dc2012-09-19 14:03:08 -0700185 *DependentPipelineManager*
186 The dependent pipeline manager is designed for gating. It ensures
James E. Blaircdd00072012-06-08 19:17:28 -0700187 that every change is tested exactly as it is going to be merged
188 into the repository. An ideal gating system would test one change
189 at a time, applied to the tip of the repository, and only if that
190 change passed tests would it be merged. Then the next change in
191 line would be tested the same way. In order to achieve parallel
Clark Boylan00635dc2012-09-19 14:03:08 -0700192 testing of changes, the dependent pipeline manager performs
James E. Blaircdd00072012-06-08 19:17:28 -0700193 speculative execution on changes. It orders changes based on
Clark Boylan00635dc2012-09-19 14:03:08 -0700194 their entry into the pipeline. It begins testing all changes in
195 parallel, assuming that each change ahead in the pipeline will pass
James E. Blaircdd00072012-06-08 19:17:28 -0700196 its tests. If they all succeed, all the changes can be tested and
Clark Boylan00635dc2012-09-19 14:03:08 -0700197 merged in parallel. If a change near the front of the pipeline
198 fails its tests, each change behind it ignores whatever tests have
199 been completed and are tested again without the change in front.
200 This way gate tests may run in parallel but still be tested
201 correctly, exactly as they will appear in the repository when
202 merged.
James E. Blaircdd00072012-06-08 19:17:28 -0700203
Clark Boylan00635dc2012-09-19 14:03:08 -0700204 One important characteristic of the DependentPipelineManager is that
James E. Blaircdd00072012-06-08 19:17:28 -0700205 it analyzes the jobs that are triggered by different projects, and
206 if those projects have jobs in common, it treats those projects as
207 related, and they share a single virtual queue of changes. Thus,
208 if there is a job that performs integration testing on two
209 projects, those two projects will automatically share a virtual
210 change queue. If a third project does not invoke that job, it
Clark Boylan00635dc2012-09-19 14:03:08 -0700211 will be part of a separate virtual change queue, and changes to
212 it will not depend on changes to the first two jobs.
James E. Blaircdd00072012-06-08 19:17:28 -0700213
214 For more detail on the theory and operation of Zuul's
Clark Boylan00635dc2012-09-19 14:03:08 -0700215 DependentPipelineManager, see: :doc:`gating`.
James E. Blaircdd00072012-06-08 19:17:28 -0700216
217**trigger**
Clark Boylan00635dc2012-09-19 14:03:08 -0700218 This describes what Gerrit events should be placed in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700219 Triggers are not exclusive -- matching events may be placed in
Clark Boylan00635dc2012-09-19 14:03:08 -0700220 multiple pipelines, and they will behave independently in each of the
221 pipelines they match. Multiple triggers may be listed. Further
James E. Blaircdd00072012-06-08 19:17:28 -0700222 parameters describe the kind of events that match:
223
224 *event*
225 The event name from gerrit. Examples: ``patchset-created``,
226 ``comment-added``, ``ref-updated``. This field is treated as a
227 regular expression.
228
229 *branch*
230 The branch associated with the event. Example: ``master``. This
231 field is treated as a regular expression, and multiple branches may
232 be listed.
233
234 *ref*
235 On ref-updated events, the branch parameter is not used, instead the
236 ref is provided. Currently Gerrit has the somewhat idiosyncratic
237 behavior of specifying bare refs for branch names (e.g., ``master``),
238 but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
239 Zuul matches what you put here exactly against what Gerrit
240 provides. This field is treated as a regular expression, and
241 multiple refs may be listed.
242
243 *approval*
244 This is only used for ``comment-added`` events. It only matches if
245 the event has a matching approval associated with it. Example:
246 ``code-review: 2`` matches a ``+2`` vote on the code review category.
247 Multiple approvals may be listed.
248
Clark Boylanb9bcb402012-06-29 17:44:05 -0700249 *comment_filter*
250 This is only used for ``comment-added`` events. It accepts a list of
251 regexes that are searched for in the comment string. If any of these
252 regexes matches a portion of the comment string the trigger is
253 matched. ``comment_filter: retrigger`` will match when comments
254 containing 'retrigger' somewhere in the comment text are added to a
255 change.
256
James E. Blaircdd00072012-06-08 19:17:28 -0700257**success**
258 Describes what Zuul should do if all the jobs complete successfully.
259 This section is optional; if it is omitted, Zuul will run jobs and
260 do nothing on success; it will not even report a message to Gerrit.
261 If the section is present, it will leave a message on the Gerrit
262 review. Each additional argument is assumed to be an argument to
263 ``gerrit review``, with the boolean value of ``true`` simply
264 indicating that the argument should be present without following it
265 with a value. For example, ``verified: 1`` becomes ``gerrit
266 review --verified 1`` and ``submit: true`` becomes ``gerrit review
267 --submit``.
268
269**failure**
270 Uses the same syntax as **success**, but describes what Zuul should
271 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700272
273**start**
274 Uses the same syntax as **success**, but describes what Zuul should
Clark Boylan00635dc2012-09-19 14:03:08 -0700275 do when a change is added to the pipeline manager. This can be used,
James E. Blairdc253862012-06-13 17:12:42 -0700276 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700277
Clark Boylan00635dc2012-09-19 14:03:08 -0700278Some example pipeline configurations are included in the sample layout
279file. The first is called a *check* pipeline::
James E. Blaircdd00072012-06-08 19:17:28 -0700280
281 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700282 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700283 trigger:
284 - event: patchset-created
285 success:
286 verified: 1
287 failure:
288 verified: -1
289
290This will trigger jobs each time a new patchset (or change) is
291uploaded to Gerrit, and report +/-1 values to Gerrit in the
292``verified`` review category. ::
293
294 - name: gate
Clark Boylan00635dc2012-09-19 14:03:08 -0700295 manager: DependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700296 trigger:
297 - event: comment-added
298 approval:
299 - approved: 1
300 success:
301 verified: 2
302 submit: true
303 failure:
304 verified: -2
305
306This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
307``approved`` review category in Gerrit (a non-standard category).
308Changes will be tested in such a way as to guarantee that they will be
309merged exactly as tested, though that will happen in parallel by
310creating a virtual queue of dependent changes and performing
311speculative execution of jobs. ::
312
313 - name: post
Clark Boylan00635dc2012-09-19 14:03:08 -0700314 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700315 trigger:
316 - event: ref-updated
317 ref: ^(?!refs/).*$
318
319This will trigger jobs whenever a change is merged to a named branch
320(e.g., ``master``). No output will be reported to Gerrit. This is
321useful for side effects such as creating per-commit tarballs. ::
322
323 - name: silent
Clark Boylan00635dc2012-09-19 14:03:08 -0700324 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700325 trigger:
326 - event: patchset-created
327
328This also triggers jobs when changes are uploaded to Gerrit, but no
329results are reported to Gerrit. This is useful for jobs that are in
Antoine Mussoce333842012-10-16 14:42:35 +0200330development and not yet ready to be presented to developers. ::
331
332 pipelines:
333 - name: post-merge
334 manager: IndependentPipelineManager
335 trigger:
336 - event: change-merged
337 success:
338 force-message: True
339 failure:
340 force-message: True
341
342The ``change-merged`` events happen when a change has been merged in the git
343repository. The change is thus closed and Gerrit will not accept modifications
344to the review scoring such as ``code-review`` or ``verified``. By using the
345``force-message: True`` parameter, Zuul will pass ``--force-message`` to the
346``gerrit review`` command, thus making sure the message is actually
347sent back to Gerrit regardless of approval scores.
348That kind of pipeline is nice to run regression or performance tests.
349
350.. note::
351 The ``change-merged`` event does not include the commit sha1 which can be
352 hazardous, it would let you report back to Gerrit though. If you were to
353 build a tarball for a specific commit, you should consider insteading using
354 the ``ref-updated`` event which does include the commit sha1 (but lack the
355 Gerrit change number).
James E. Blaircdd00072012-06-08 19:17:28 -0700356
357Jobs
358""""
359
360The jobs section is optional, and can be used to set attributes of
361jobs that are independent of their association with a project. For
362example, if a job should return a customized message on failure, that
363may be specified here. Otherwise, Zuul does not need to be told about
364each job as it builds a list from the project specification.
365
366**name**
367 The name of the job. This field is treated as a regular expression
368 and will be applied to each job that matches.
369
James E. Blaire5a847f2012-07-10 15:29:14 -0700370**failure-message (optional)**
371 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700372
James E. Blaire5a847f2012-07-10 15:29:14 -0700373**success-message (optional)**
374 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700375
James E. Blair222d4982012-07-16 09:31:19 -0700376**hold-following-changes (optional)**
377 This is a boolean that indicates that changes that follow this
Clark Boylan00635dc2012-09-19 14:03:08 -0700378 change in a dependent change pipeline should wait until this job
James E. Blair222d4982012-07-16 09:31:19 -0700379 succeeds before launching. If this is applied to a very short job
380 that can predict whether longer jobs will fail early, this can be
381 used to reduce the number of jobs that Zuul will launch and
382 ultimately have to cancel. In that case, a small amount of
383 paralellization of jobs is traded for more efficient use of testing
384 resources. On the other hand, to apply this to a long running job
385 would largely defeat the parallelization of dependent change testing
386 that is the main feature of Zuul. The default is False.
387
James E. Blaire5a847f2012-07-10 15:29:14 -0700388**branch (optional)**
James E. Blaircdd00072012-06-08 19:17:28 -0700389 This job should only be run on matching branches. This field is
390 treated as a regular expression and multiple branches may be
391 listed.
392
James E. Blaire5a847f2012-07-10 15:29:14 -0700393**parameter-function (optional)**
394 Specifies a function that should be applied to the parameters before
395 the job is launched. The function should be defined in a python file
396 included with the :ref:`includes` directive. The function
397 should have the following signature:
398
399 .. function:: parameters(change, parameters)
400
401 Manipulate the parameters passed to a job before a build is
402 launched. The ``parameters`` dictionary will already contain the
403 standard Zuul job parameters, and is expected to be modified
404 in-place.
405
406 :param change: the current change
407 :type change: zuul.model.Change
408 :param parameters: parameters to be passed to the job
409 :type parameters: dict
410
James E. Blaircdd00072012-06-08 19:17:28 -0700411Here is an example of setting the failure message for jobs that check
412whether a change merges cleanly::
413
414 - name: ^.*-merge$
415 failure-message: This change was unable to be automatically merged
416 with the current state of the repository. Please rebase your
417 change and upload a new patchset.
418
419Projects
420""""""""
421
Clark Boylan00635dc2012-09-19 14:03:08 -0700422The projects section indicates what jobs should be run in each pipeline
James E. Blaircdd00072012-06-08 19:17:28 -0700423for events associated with each project. It contains a list of
424projects. Here is an example::
425
426 - name: example/project
427 check:
428 - project-merge:
429 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700430 - project-pep8
431 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700432 gate:
433 - project-merge:
434 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700435 - project-pep8
436 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700437 post:
438 - project-publish
439
440**name**
441 The name of the project (as known by Gerrit).
442
Clark Boylan00635dc2012-09-19 14:03:08 -0700443This is followed by a section for each of the pipelines defined above.
444Pipelines may be omitted if no jobs should run for this project in a
445given pipeline. Within the pipeline section, the jobs that should be
James E. Blaircdd00072012-06-08 19:17:28 -0700446executed are listed. If a job is entered as a dictionary key, then
447jobs contained within that key are only executed if the key job
448succeeds. In the above example, project-unittest, project-pep8, and
449project-pyflakes are only executed if project-merge succeeds. This
450can help avoid running unnecessary jobs.
451
Antoine Mussofec5c7a2012-09-22 12:32:37 +0200452.. 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 -0700453
454
455logging.conf
456~~~~~~~~~~~~
457This file is optional. If provided, it should be a standard
458:mod:`logging.config` module configuration file. If not present, Zuul will
459output all log messages of DEBUG level or higher to the console.
460
461Starting Zuul
462-------------
463
464To start Zuul, run **zuul-server**::
465
466 usage: zuul-server [-h] [-c CONFIG] [-d]
467
468 Project gating system.
469
470 optional arguments:
471 -h, --help show this help message and exit
472 -c CONFIG specify the config file
473 -d do not run as a daemon
474
475You may want to use the ``-d`` argument while you are initially setting
476up Zuul so you can detect any configuration errors quickly. Under
477normal operation, omit ``-d`` and let Zuul run as a daemon.
478
479If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
480stop executing new jobs, wait until all executing jobs are finished,
481reload its configuration, and resume. Any values in any of the
482configuration files may be changed, except the location of Zuul's PID
483file (a change to that will be ignored until Zuul is restarted).