blob: 416174dd2ae82f05a0ecb350dee3aeb1335365ff [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
Antoine Mussob4e809e2012-12-06 16:58:06 +0100249 *email_filter*
250 This is used for any event. It takes a regex applied on the performer
251 email. Example: ``email_filter: .*@example.org$``.
252
Clark Boylanb9bcb402012-06-29 17:44:05 -0700253 *comment_filter*
254 This is only used for ``comment-added`` events. It accepts a list of
255 regexes that are searched for in the comment string. If any of these
256 regexes matches a portion of the comment string the trigger is
257 matched. ``comment_filter: retrigger`` will match when comments
258 containing 'retrigger' somewhere in the comment text are added to a
259 change.
260
James E. Blaircdd00072012-06-08 19:17:28 -0700261**success**
262 Describes what Zuul should do if all the jobs complete successfully.
263 This section is optional; if it is omitted, Zuul will run jobs and
264 do nothing on success; it will not even report a message to Gerrit.
265 If the section is present, it will leave a message on the Gerrit
266 review. Each additional argument is assumed to be an argument to
267 ``gerrit review``, with the boolean value of ``true`` simply
268 indicating that the argument should be present without following it
269 with a value. For example, ``verified: 1`` becomes ``gerrit
270 review --verified 1`` and ``submit: true`` becomes ``gerrit review
271 --submit``.
272
273**failure**
274 Uses the same syntax as **success**, but describes what Zuul should
275 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700276
277**start**
278 Uses the same syntax as **success**, but describes what Zuul should
Clark Boylan00635dc2012-09-19 14:03:08 -0700279 do when a change is added to the pipeline manager. This can be used,
James E. Blairdc253862012-06-13 17:12:42 -0700280 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700281
Clark Boylan00635dc2012-09-19 14:03:08 -0700282Some example pipeline configurations are included in the sample layout
283file. The first is called a *check* pipeline::
James E. Blaircdd00072012-06-08 19:17:28 -0700284
285 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700286 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700287 trigger:
288 - event: patchset-created
289 success:
290 verified: 1
291 failure:
292 verified: -1
293
294This will trigger jobs each time a new patchset (or change) is
295uploaded to Gerrit, and report +/-1 values to Gerrit in the
296``verified`` review category. ::
297
298 - name: gate
Clark Boylan00635dc2012-09-19 14:03:08 -0700299 manager: DependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700300 trigger:
301 - event: comment-added
302 approval:
303 - approved: 1
304 success:
305 verified: 2
306 submit: true
307 failure:
308 verified: -2
309
310This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
311``approved`` review category in Gerrit (a non-standard category).
312Changes will be tested in such a way as to guarantee that they will be
313merged exactly as tested, though that will happen in parallel by
314creating a virtual queue of dependent changes and performing
315speculative execution of jobs. ::
316
317 - name: post
Clark Boylan00635dc2012-09-19 14:03:08 -0700318 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700319 trigger:
320 - event: ref-updated
321 ref: ^(?!refs/).*$
322
323This will trigger jobs whenever a change is merged to a named branch
324(e.g., ``master``). No output will be reported to Gerrit. This is
325useful for side effects such as creating per-commit tarballs. ::
326
327 - name: silent
Clark Boylan00635dc2012-09-19 14:03:08 -0700328 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700329 trigger:
330 - event: patchset-created
331
332This also triggers jobs when changes are uploaded to Gerrit, but no
333results are reported to Gerrit. This is useful for jobs that are in
Antoine Mussoce333842012-10-16 14:42:35 +0200334development and not yet ready to be presented to developers. ::
335
336 pipelines:
337 - name: post-merge
338 manager: IndependentPipelineManager
339 trigger:
340 - event: change-merged
341 success:
342 force-message: True
343 failure:
344 force-message: True
345
346The ``change-merged`` events happen when a change has been merged in the git
347repository. The change is thus closed and Gerrit will not accept modifications
348to the review scoring such as ``code-review`` or ``verified``. By using the
349``force-message: True`` parameter, Zuul will pass ``--force-message`` to the
350``gerrit review`` command, thus making sure the message is actually
351sent back to Gerrit regardless of approval scores.
352That kind of pipeline is nice to run regression or performance tests.
353
354.. note::
355 The ``change-merged`` event does not include the commit sha1 which can be
356 hazardous, it would let you report back to Gerrit though. If you were to
357 build a tarball for a specific commit, you should consider insteading using
358 the ``ref-updated`` event which does include the commit sha1 (but lack the
359 Gerrit change number).
James E. Blaircdd00072012-06-08 19:17:28 -0700360
361Jobs
362""""
363
364The jobs section is optional, and can be used to set attributes of
365jobs that are independent of their association with a project. For
366example, if a job should return a customized message on failure, that
367may be specified here. Otherwise, Zuul does not need to be told about
368each job as it builds a list from the project specification.
369
370**name**
371 The name of the job. This field is treated as a regular expression
372 and will be applied to each job that matches.
373
James E. Blaire5a847f2012-07-10 15:29:14 -0700374**failure-message (optional)**
375 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700376
James E. Blaire5a847f2012-07-10 15:29:14 -0700377**success-message (optional)**
378 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700379
James E. Blair222d4982012-07-16 09:31:19 -0700380**hold-following-changes (optional)**
381 This is a boolean that indicates that changes that follow this
Clark Boylan00635dc2012-09-19 14:03:08 -0700382 change in a dependent change pipeline should wait until this job
James E. Blair222d4982012-07-16 09:31:19 -0700383 succeeds before launching. If this is applied to a very short job
384 that can predict whether longer jobs will fail early, this can be
385 used to reduce the number of jobs that Zuul will launch and
386 ultimately have to cancel. In that case, a small amount of
387 paralellization of jobs is traded for more efficient use of testing
388 resources. On the other hand, to apply this to a long running job
389 would largely defeat the parallelization of dependent change testing
390 that is the main feature of Zuul. The default is False.
391
James E. Blaire5a847f2012-07-10 15:29:14 -0700392**branch (optional)**
James E. Blaircdd00072012-06-08 19:17:28 -0700393 This job should only be run on matching branches. This field is
394 treated as a regular expression and multiple branches may be
395 listed.
396
James E. Blaire5a847f2012-07-10 15:29:14 -0700397**parameter-function (optional)**
398 Specifies a function that should be applied to the parameters before
399 the job is launched. The function should be defined in a python file
400 included with the :ref:`includes` directive. The function
401 should have the following signature:
402
403 .. function:: parameters(change, parameters)
404
405 Manipulate the parameters passed to a job before a build is
406 launched. The ``parameters`` dictionary will already contain the
407 standard Zuul job parameters, and is expected to be modified
408 in-place.
409
410 :param change: the current change
411 :type change: zuul.model.Change
412 :param parameters: parameters to be passed to the job
413 :type parameters: dict
414
James E. Blaircdd00072012-06-08 19:17:28 -0700415Here is an example of setting the failure message for jobs that check
416whether a change merges cleanly::
417
418 - name: ^.*-merge$
419 failure-message: This change was unable to be automatically merged
420 with the current state of the repository. Please rebase your
421 change and upload a new patchset.
422
423Projects
424""""""""
425
Clark Boylan00635dc2012-09-19 14:03:08 -0700426The projects section indicates what jobs should be run in each pipeline
James E. Blaircdd00072012-06-08 19:17:28 -0700427for events associated with each project. It contains a list of
428projects. Here is an example::
429
430 - name: example/project
431 check:
432 - project-merge:
433 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700434 - project-pep8
435 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700436 gate:
437 - project-merge:
438 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700439 - project-pep8
440 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700441 post:
442 - project-publish
443
444**name**
445 The name of the project (as known by Gerrit).
446
Clark Boylan00635dc2012-09-19 14:03:08 -0700447This is followed by a section for each of the pipelines defined above.
448Pipelines may be omitted if no jobs should run for this project in a
449given pipeline. Within the pipeline section, the jobs that should be
James E. Blaircdd00072012-06-08 19:17:28 -0700450executed are listed. If a job is entered as a dictionary key, then
451jobs contained within that key are only executed if the key job
452succeeds. In the above example, project-unittest, project-pep8, and
453project-pyflakes are only executed if project-merge succeeds. This
454can help avoid running unnecessary jobs.
455
Antoine Mussofec5c7a2012-09-22 12:32:37 +0200456.. 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 -0700457
458
459logging.conf
460~~~~~~~~~~~~
461This file is optional. If provided, it should be a standard
462:mod:`logging.config` module configuration file. If not present, Zuul will
463output all log messages of DEBUG level or higher to the console.
464
465Starting Zuul
466-------------
467
468To start Zuul, run **zuul-server**::
469
470 usage: zuul-server [-h] [-c CONFIG] [-d]
471
472 Project gating system.
473
474 optional arguments:
475 -h, --help show this help message and exit
476 -c CONFIG specify the config file
477 -d do not run as a daemon
478
479You may want to use the ``-d`` argument while you are initially setting
480up Zuul so you can detect any configuration errors quickly. Under
481normal operation, omit ``-d`` and let Zuul run as a daemon.
482
483If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
484stop executing new jobs, wait until all executing jobs are finished,
485reload its configuration, and resume. Any values in any of the
486configuration files may be changed, except the location of Zuul's PID
487file (a change to that will be ignored until Zuul is restarted).