blob: 55e020138e9127cf46d2a56abbfe19cfcbb34beb [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
James E. Blair6aea36d2012-12-17 13:03:24 -080021.. _zuulconf:
22
James E. Blaircdd00072012-06-08 19:17:28 -070023zuul.conf
24~~~~~~~~~
25
26Zuul will look for ``/etc/zuul/zuul.conf`` or ``~/zuul.conf`` to
27bootstrap its configuration. Alternately, you may specify ``-c
28/path/to/zuul.conf`` on the command line.
29
30Gerrit and Jenkins credentials are each described in a section of
31zuul.conf. The location of the other two configuration files (as well
32as the location of the PID file when running Zuul as a server) are
33specified in a third section.
34
Clark Boylan9b670902012-09-28 13:47:56 -070035The three sections of this config and their options are documented below.
36You can also find an example zuul.conf file in the git
37`repository
38<https://github.com/openstack-ci/zuul/blob/master/etc/zuul.conf-sample>`_
39
40jenkins
41"""""""
42
43**server**
44 URL for the root of the Jenkins HTTP server.
45 ``server=https://jenkins.example.com``
46
47**user**
48 User to authenticate against Jenkins with.
49 ``user=jenkins``
50
51**apikey**
52 Jenkins API Key credentials for the above user.
53 ``apikey=1234567890abcdef1234567890abcdef``
54
55gerrit
56""""""
57
58**server**
59 FQDN of Gerrit server.
60 ``server=review.example.com``
61
Antoine Musso27475012012-11-26 09:53:01 +010062**baseurl**
63 Optional: path to Gerrit web interface. Defaults to ``https://<value
64 of server>/``. ``baseurl=https://review.example.com/review_site/``
65
Clark Boylan9b670902012-09-28 13:47:56 -070066**user**
67 User name to use when logging into above server via ssh.
68 ``user=jenkins``
69
70**sshkey**
71 Path to SSH key to use when logging into above server.
72 ``sshkey=/home/jenkins/.ssh/id_rsa``
73
74zuul
75""""
76
77**layout_config**
78 Path to layout config file.
79 ``layout_config=/etc/zuul/layout.yaml``
80
81**log_config**
82 Path to log config file.
83 ``log_config=/etc/zuul/logging.yaml``
84
85**pidfile**
86 Path to PID lock file.
87 ``pidfile=/var/run/zuul/zuul.pid``
88
89**state_dir**
90 Path to directory that Zuul should save state to.
91 ``state_dir=/var/lib/zuul``
92
93**git_dir**
94 Directory that Zuul should clone local git repositories to.
95 ``git_dir=/var/lib/zuul/git``
96
97**push_change_refs**
98 Boolean value (``true`` or ``false``) that determines if Zuul should
99 push change refs to the git origin server for the git repositories in
100 git_dir.
101 ``push_change_refs=true``
102
103**status_url**
104 URL that will be posted in Zuul comments made to Gerrit changes when
105 beginning Jenkins jobs for a change.
106 ``status_url=https://jenkins.example.com/zuul/status``
107
108**url_pattern**
109 If you are storing build logs external to Jenkins and wish to link to
110 those logs when Zuul makes comments on Gerrit changes for completed
111 jobs this setting configures what the URLs for those links should be.
112 ``http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number}``
113
James E. Blaircdd00072012-06-08 19:17:28 -0700114layout.yaml
115~~~~~~~~~~~
116
Clark Boylan00635dc2012-09-19 14:03:08 -0700117This is the main configuration file for Zuul, where all of the pipelines
James E. Blaircdd00072012-06-08 19:17:28 -0700118and projects are defined, what tests should be run, and what actions
Clark Boylan00635dc2012-09-19 14:03:08 -0700119Zuul should perform. There are three sections: pipelines, jobs, and
James E. Blaircdd00072012-06-08 19:17:28 -0700120projects.
121
James E. Blaire5a847f2012-07-10 15:29:14 -0700122.. _includes:
123
124Includes
125""""""""
126
127Custom functions to be used in Zuul's configuration may be provided
128using the ``includes`` directive. It accepts a list of files to
129include, and currently supports one type of inclusion, a python file::
130
131 includes:
132 - python-file: local_functions.py
133
134**python-file**
135 The path to a python file. The file will be loaded and objects that
136 it defines will be placed in a special environment which can be
137 referenced in the Zuul configuration. Currently only the
138 parameter-function attribute of a Job uses this feature.
139
Clark Boylan00635dc2012-09-19 14:03:08 -0700140Pipelines
141"""""""""
James E. Blaircdd00072012-06-08 19:17:28 -0700142
Clark Boylan00635dc2012-09-19 14:03:08 -0700143Zuul can have any number of independent pipelines. Whenever a matching
144Gerrit event is found for a pipeline, that event is added to the
145pipeline, and the jobs specified for that pipeline are run. When all
146jobs specified for the pipeline that were triggered by an event are
147completed, Zuul reports back to Gerrit the results.
James E. Blaircdd00072012-06-08 19:17:28 -0700148
Clark Boylan00635dc2012-09-19 14:03:08 -0700149There are no pre-defined pipelines in Zuul, rather you can define
150whatever pipelines you need in the layout file. This is a very flexible
151system that can accommodate many kinds of workflows.
James E. Blaircdd00072012-06-08 19:17:28 -0700152
Clark Boylan00635dc2012-09-19 14:03:08 -0700153Here is a quick example of a pipeline definition followed by an
James E. Blaircdd00072012-06-08 19:17:28 -0700154explanation of each of the parameters::
155
156 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700157 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700158 trigger:
159 - event: patchset-created
160 success:
161 verified: 1
162 failure:
163 verified: -1
164
165**name**
166 This is used later in the project definition to indicate what jobs
Clark Boylan00635dc2012-09-19 14:03:08 -0700167 should be run for events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700168
James E. Blair8dbd56a2012-12-22 10:55:10 -0800169**description**
170 This is an optional field that may be used to provide a textual
171 description of the pipeline.
172
James E. Blaircdd00072012-06-08 19:17:28 -0700173**manager**
Clark Boylan00635dc2012-09-19 14:03:08 -0700174 There are currently two schemes for managing pipelines:
James E. Blaircdd00072012-06-08 19:17:28 -0700175
Clark Boylan00635dc2012-09-19 14:03:08 -0700176 *IndependentPipelineManager*
177 Every event in this pipeline should be treated as independent of
178 other events in the pipeline. This is appropriate when the order of
179 events in the pipeline doesn't matter because the results of the
180 actions this pipeline performs can not affect other events in the
181 pipeline. For example, when a change is first uploaded for review,
James E. Blaircdd00072012-06-08 19:17:28 -0700182 you may want to run tests on that change to provide early feedback
183 to reviewers. At the end of the tests, the change is not going to
184 be merged, so it is safe to run these tests in parallel without
Clark Boylan00635dc2012-09-19 14:03:08 -0700185 regard to any other changes in the pipeline. They are independent.
James E. Blaircdd00072012-06-08 19:17:28 -0700186
Clark Boylan00635dc2012-09-19 14:03:08 -0700187 Another type of pipeline that is independent is a post-merge
188 pipeline. In that case, the changes have already merged, so the
189 results can not affect any other events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700190
Clark Boylan00635dc2012-09-19 14:03:08 -0700191 *DependentPipelineManager*
192 The dependent pipeline manager is designed for gating. It ensures
James E. Blaircdd00072012-06-08 19:17:28 -0700193 that every change is tested exactly as it is going to be merged
194 into the repository. An ideal gating system would test one change
195 at a time, applied to the tip of the repository, and only if that
196 change passed tests would it be merged. Then the next change in
197 line would be tested the same way. In order to achieve parallel
Clark Boylan00635dc2012-09-19 14:03:08 -0700198 testing of changes, the dependent pipeline manager performs
James E. Blaircdd00072012-06-08 19:17:28 -0700199 speculative execution on changes. It orders changes based on
Clark Boylan00635dc2012-09-19 14:03:08 -0700200 their entry into the pipeline. It begins testing all changes in
201 parallel, assuming that each change ahead in the pipeline will pass
James E. Blaircdd00072012-06-08 19:17:28 -0700202 its tests. If they all succeed, all the changes can be tested and
Clark Boylan00635dc2012-09-19 14:03:08 -0700203 merged in parallel. If a change near the front of the pipeline
204 fails its tests, each change behind it ignores whatever tests have
205 been completed and are tested again without the change in front.
206 This way gate tests may run in parallel but still be tested
207 correctly, exactly as they will appear in the repository when
208 merged.
James E. Blaircdd00072012-06-08 19:17:28 -0700209
Clark Boylan00635dc2012-09-19 14:03:08 -0700210 One important characteristic of the DependentPipelineManager is that
James E. Blaircdd00072012-06-08 19:17:28 -0700211 it analyzes the jobs that are triggered by different projects, and
212 if those projects have jobs in common, it treats those projects as
213 related, and they share a single virtual queue of changes. Thus,
214 if there is a job that performs integration testing on two
215 projects, those two projects will automatically share a virtual
216 change queue. If a third project does not invoke that job, it
Clark Boylan00635dc2012-09-19 14:03:08 -0700217 will be part of a separate virtual change queue, and changes to
218 it will not depend on changes to the first two jobs.
James E. Blaircdd00072012-06-08 19:17:28 -0700219
220 For more detail on the theory and operation of Zuul's
Clark Boylan00635dc2012-09-19 14:03:08 -0700221 DependentPipelineManager, see: :doc:`gating`.
James E. Blaircdd00072012-06-08 19:17:28 -0700222
223**trigger**
Clark Boylan00635dc2012-09-19 14:03:08 -0700224 This describes what Gerrit events should be placed in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700225 Triggers are not exclusive -- matching events may be placed in
Clark Boylan00635dc2012-09-19 14:03:08 -0700226 multiple pipelines, and they will behave independently in each of the
227 pipelines they match. Multiple triggers may be listed. Further
James E. Blaircdd00072012-06-08 19:17:28 -0700228 parameters describe the kind of events that match:
229
230 *event*
231 The event name from gerrit. Examples: ``patchset-created``,
232 ``comment-added``, ``ref-updated``. This field is treated as a
233 regular expression.
234
235 *branch*
236 The branch associated with the event. Example: ``master``. This
237 field is treated as a regular expression, and multiple branches may
238 be listed.
239
240 *ref*
241 On ref-updated events, the branch parameter is not used, instead the
242 ref is provided. Currently Gerrit has the somewhat idiosyncratic
243 behavior of specifying bare refs for branch names (e.g., ``master``),
244 but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
245 Zuul matches what you put here exactly against what Gerrit
246 provides. This field is treated as a regular expression, and
247 multiple refs may be listed.
248
249 *approval*
250 This is only used for ``comment-added`` events. It only matches if
251 the event has a matching approval associated with it. Example:
252 ``code-review: 2`` matches a ``+2`` vote on the code review category.
253 Multiple approvals may be listed.
254
Antoine Mussob4e809e2012-12-06 16:58:06 +0100255 *email_filter*
256 This is used for any event. It takes a regex applied on the performer
Antoine Musso5f110422012-12-18 23:22:13 +0100257 email, i.e Gerrit account email address. If you want to specify
258 several email filters, you must use a YAML list. Make sure to use non
259 greedy matchers and to escapes dots!
260 Example: ``email_filter: ^.*?@example\.org$``.
Antoine Mussob4e809e2012-12-06 16:58:06 +0100261
Clark Boylanb9bcb402012-06-29 17:44:05 -0700262 *comment_filter*
263 This is only used for ``comment-added`` events. It accepts a list of
264 regexes that are searched for in the comment string. If any of these
265 regexes matches a portion of the comment string the trigger is
266 matched. ``comment_filter: retrigger`` will match when comments
267 containing 'retrigger' somewhere in the comment text are added to a
268 change.
269
James E. Blaircdd00072012-06-08 19:17:28 -0700270**success**
271 Describes what Zuul should do if all the jobs complete successfully.
272 This section is optional; if it is omitted, Zuul will run jobs and
273 do nothing on success; it will not even report a message to Gerrit.
274 If the section is present, it will leave a message on the Gerrit
275 review. Each additional argument is assumed to be an argument to
276 ``gerrit review``, with the boolean value of ``true`` simply
277 indicating that the argument should be present without following it
278 with a value. For example, ``verified: 1`` becomes ``gerrit
279 review --verified 1`` and ``submit: true`` becomes ``gerrit review
280 --submit``.
281
282**failure**
283 Uses the same syntax as **success**, but describes what Zuul should
284 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700285
286**start**
287 Uses the same syntax as **success**, but describes what Zuul should
Clark Boylan00635dc2012-09-19 14:03:08 -0700288 do when a change is added to the pipeline manager. This can be used,
James E. Blairdc253862012-06-13 17:12:42 -0700289 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700290
Clark Boylan00635dc2012-09-19 14:03:08 -0700291Some example pipeline configurations are included in the sample layout
292file. The first is called a *check* pipeline::
James E. Blaircdd00072012-06-08 19:17:28 -0700293
294 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700295 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700296 trigger:
297 - event: patchset-created
298 success:
299 verified: 1
300 failure:
301 verified: -1
302
303This will trigger jobs each time a new patchset (or change) is
304uploaded to Gerrit, and report +/-1 values to Gerrit in the
305``verified`` review category. ::
306
307 - name: gate
Clark Boylan00635dc2012-09-19 14:03:08 -0700308 manager: DependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700309 trigger:
310 - event: comment-added
311 approval:
312 - approved: 1
313 success:
314 verified: 2
315 submit: true
316 failure:
317 verified: -2
318
319This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
320``approved`` review category in Gerrit (a non-standard category).
321Changes will be tested in such a way as to guarantee that they will be
322merged exactly as tested, though that will happen in parallel by
323creating a virtual queue of dependent changes and performing
324speculative execution of jobs. ::
325
326 - name: post
Clark Boylan00635dc2012-09-19 14:03:08 -0700327 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700328 trigger:
329 - event: ref-updated
330 ref: ^(?!refs/).*$
331
332This will trigger jobs whenever a change is merged to a named branch
333(e.g., ``master``). No output will be reported to Gerrit. This is
334useful for side effects such as creating per-commit tarballs. ::
335
336 - name: silent
Clark Boylan00635dc2012-09-19 14:03:08 -0700337 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700338 trigger:
339 - event: patchset-created
340
341This also triggers jobs when changes are uploaded to Gerrit, but no
342results are reported to Gerrit. This is useful for jobs that are in
Antoine Mussoce333842012-10-16 14:42:35 +0200343development and not yet ready to be presented to developers. ::
344
345 pipelines:
346 - name: post-merge
347 manager: IndependentPipelineManager
348 trigger:
349 - event: change-merged
350 success:
351 force-message: True
352 failure:
353 force-message: True
354
355The ``change-merged`` events happen when a change has been merged in the git
356repository. The change is thus closed and Gerrit will not accept modifications
357to the review scoring such as ``code-review`` or ``verified``. By using the
358``force-message: True`` parameter, Zuul will pass ``--force-message`` to the
359``gerrit review`` command, thus making sure the message is actually
360sent back to Gerrit regardless of approval scores.
361That kind of pipeline is nice to run regression or performance tests.
362
363.. note::
364 The ``change-merged`` event does not include the commit sha1 which can be
365 hazardous, it would let you report back to Gerrit though. If you were to
366 build a tarball for a specific commit, you should consider insteading using
367 the ``ref-updated`` event which does include the commit sha1 (but lack the
368 Gerrit change number).
James E. Blaircdd00072012-06-08 19:17:28 -0700369
370Jobs
371""""
372
373The jobs section is optional, and can be used to set attributes of
374jobs that are independent of their association with a project. For
375example, if a job should return a customized message on failure, that
376may be specified here. Otherwise, Zuul does not need to be told about
377each job as it builds a list from the project specification.
378
379**name**
380 The name of the job. This field is treated as a regular expression
381 and will be applied to each job that matches.
382
James E. Blaire5a847f2012-07-10 15:29:14 -0700383**failure-message (optional)**
384 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700385
James E. Blaire5a847f2012-07-10 15:29:14 -0700386**success-message (optional)**
387 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700388
James E. Blair6aea36d2012-12-17 13:03:24 -0800389**failure-pattern (optional)**
390 The URL that should be reported to Gerrit if the job fails.
391 Defaults to the Jenkins build URL or the url_pattern configured in
392 zuul.conf. May be supplied as a string pattern with substitutions
393 as described in url_pattern in :ref:`zuulconf`.
394
395**success-pattern (optional)**
396 The URL that should be reported to Gerrit if the job succeeds.
397 Defaults to the Jenkins build URL or the url_pattern configured in
398 zuul.conf. May be supplied as a string pattern with substitutions
399 as described in url_pattern in :ref:`zuulconf`.
400
James E. Blair222d4982012-07-16 09:31:19 -0700401**hold-following-changes (optional)**
402 This is a boolean that indicates that changes that follow this
Clark Boylan00635dc2012-09-19 14:03:08 -0700403 change in a dependent change pipeline should wait until this job
James E. Blair222d4982012-07-16 09:31:19 -0700404 succeeds before launching. If this is applied to a very short job
405 that can predict whether longer jobs will fail early, this can be
406 used to reduce the number of jobs that Zuul will launch and
407 ultimately have to cancel. In that case, a small amount of
408 paralellization of jobs is traded for more efficient use of testing
409 resources. On the other hand, to apply this to a long running job
410 would largely defeat the parallelization of dependent change testing
411 that is the main feature of Zuul. The default is False.
412
James E. Blaire5a847f2012-07-10 15:29:14 -0700413**branch (optional)**
James E. Blaircdd00072012-06-08 19:17:28 -0700414 This job should only be run on matching branches. This field is
415 treated as a regular expression and multiple branches may be
416 listed.
417
James E. Blaire5a847f2012-07-10 15:29:14 -0700418**parameter-function (optional)**
419 Specifies a function that should be applied to the parameters before
420 the job is launched. The function should be defined in a python file
421 included with the :ref:`includes` directive. The function
422 should have the following signature:
423
424 .. function:: parameters(change, parameters)
425
426 Manipulate the parameters passed to a job before a build is
427 launched. The ``parameters`` dictionary will already contain the
428 standard Zuul job parameters, and is expected to be modified
429 in-place.
430
431 :param change: the current change
432 :type change: zuul.model.Change
433 :param parameters: parameters to be passed to the job
434 :type parameters: dict
435
James E. Blaircdd00072012-06-08 19:17:28 -0700436Here is an example of setting the failure message for jobs that check
437whether a change merges cleanly::
438
439 - name: ^.*-merge$
440 failure-message: This change was unable to be automatically merged
441 with the current state of the repository. Please rebase your
442 change and upload a new patchset.
443
444Projects
445""""""""
446
Clark Boylan00635dc2012-09-19 14:03:08 -0700447The projects section indicates what jobs should be run in each pipeline
James E. Blaircdd00072012-06-08 19:17:28 -0700448for events associated with each project. It contains a list of
449projects. Here is an example::
450
451 - name: example/project
452 check:
453 - project-merge:
454 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700455 - project-pep8
456 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700457 gate:
458 - project-merge:
459 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700460 - project-pep8
461 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700462 post:
463 - project-publish
464
465**name**
466 The name of the project (as known by Gerrit).
467
Clark Boylan00635dc2012-09-19 14:03:08 -0700468This is followed by a section for each of the pipelines defined above.
469Pipelines may be omitted if no jobs should run for this project in a
470given pipeline. Within the pipeline section, the jobs that should be
James E. Blaircdd00072012-06-08 19:17:28 -0700471executed are listed. If a job is entered as a dictionary key, then
472jobs contained within that key are only executed if the key job
473succeeds. In the above example, project-unittest, project-pep8, and
474project-pyflakes are only executed if project-merge succeeds. This
475can help avoid running unnecessary jobs.
476
Antoine Mussofec5c7a2012-09-22 12:32:37 +0200477.. 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 -0700478
479
480logging.conf
481~~~~~~~~~~~~
482This file is optional. If provided, it should be a standard
483:mod:`logging.config` module configuration file. If not present, Zuul will
484output all log messages of DEBUG level or higher to the console.
485
486Starting Zuul
487-------------
488
489To start Zuul, run **zuul-server**::
490
491 usage: zuul-server [-h] [-c CONFIG] [-d]
492
493 Project gating system.
494
495 optional arguments:
496 -h, --help show this help message and exit
497 -c CONFIG specify the config file
498 -d do not run as a daemon
499
500You may want to use the ``-d`` argument while you are initially setting
501up Zuul so you can detect any configuration errors quickly. Under
502normal operation, omit ``-d`` and let Zuul run as a daemon.
503
504If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
505stop executing new jobs, wait until all executing jobs are finished,
506reload its configuration, and resume. Any values in any of the
507configuration files may be changed, except the location of Zuul's PID
508file (a change to that will be ignored until Zuul is restarted).