blob: 4f661269a3bdf64e3699bd1c4bc8baaab690a335 [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
60**user**
61 User name to use when logging into above server via ssh.
62 ``user=jenkins``
63
64**sshkey**
65 Path to SSH key to use when logging into above server.
66 ``sshkey=/home/jenkins/.ssh/id_rsa``
67
68zuul
69""""
70
71**layout_config**
72 Path to layout config file.
73 ``layout_config=/etc/zuul/layout.yaml``
74
75**log_config**
76 Path to log config file.
77 ``log_config=/etc/zuul/logging.yaml``
78
79**pidfile**
80 Path to PID lock file.
81 ``pidfile=/var/run/zuul/zuul.pid``
82
83**state_dir**
84 Path to directory that Zuul should save state to.
85 ``state_dir=/var/lib/zuul``
86
87**git_dir**
88 Directory that Zuul should clone local git repositories to.
89 ``git_dir=/var/lib/zuul/git``
90
91**push_change_refs**
92 Boolean value (``true`` or ``false``) that determines if Zuul should
93 push change refs to the git origin server for the git repositories in
94 git_dir.
95 ``push_change_refs=true``
96
97**status_url**
98 URL that will be posted in Zuul comments made to Gerrit changes when
99 beginning Jenkins jobs for a change.
100 ``status_url=https://jenkins.example.com/zuul/status``
101
102**url_pattern**
103 If you are storing build logs external to Jenkins and wish to link to
104 those logs when Zuul makes comments on Gerrit changes for completed
105 jobs this setting configures what the URLs for those links should be.
106 ``http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number}``
107
James E. Blaircdd00072012-06-08 19:17:28 -0700108layout.yaml
109~~~~~~~~~~~
110
Clark Boylan00635dc2012-09-19 14:03:08 -0700111This is the main configuration file for Zuul, where all of the pipelines
James E. Blaircdd00072012-06-08 19:17:28 -0700112and projects are defined, what tests should be run, and what actions
Clark Boylan00635dc2012-09-19 14:03:08 -0700113Zuul should perform. There are three sections: pipelines, jobs, and
James E. Blaircdd00072012-06-08 19:17:28 -0700114projects.
115
James E. Blaire5a847f2012-07-10 15:29:14 -0700116.. _includes:
117
118Includes
119""""""""
120
121Custom functions to be used in Zuul's configuration may be provided
122using the ``includes`` directive. It accepts a list of files to
123include, and currently supports one type of inclusion, a python file::
124
125 includes:
126 - python-file: local_functions.py
127
128**python-file**
129 The path to a python file. The file will be loaded and objects that
130 it defines will be placed in a special environment which can be
131 referenced in the Zuul configuration. Currently only the
132 parameter-function attribute of a Job uses this feature.
133
Clark Boylan00635dc2012-09-19 14:03:08 -0700134Pipelines
135"""""""""
James E. Blaircdd00072012-06-08 19:17:28 -0700136
Clark Boylan00635dc2012-09-19 14:03:08 -0700137Zuul can have any number of independent pipelines. Whenever a matching
138Gerrit event is found for a pipeline, that event is added to the
139pipeline, and the jobs specified for that pipeline are run. When all
140jobs specified for the pipeline that were triggered by an event are
141completed, Zuul reports back to Gerrit the results.
James E. Blaircdd00072012-06-08 19:17:28 -0700142
Clark Boylan00635dc2012-09-19 14:03:08 -0700143There are no pre-defined pipelines in Zuul, rather you can define
144whatever pipelines you need in the layout file. This is a very flexible
145system that can accommodate many kinds of workflows.
James E. Blaircdd00072012-06-08 19:17:28 -0700146
Clark Boylan00635dc2012-09-19 14:03:08 -0700147Here is a quick example of a pipeline definition followed by an
James E. Blaircdd00072012-06-08 19:17:28 -0700148explanation of each of the parameters::
149
150 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700151 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700152 trigger:
153 - event: patchset-created
154 success:
155 verified: 1
156 failure:
157 verified: -1
158
159**name**
160 This is used later in the project definition to indicate what jobs
Clark Boylan00635dc2012-09-19 14:03:08 -0700161 should be run for events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700162
163**manager**
Clark Boylan00635dc2012-09-19 14:03:08 -0700164 There are currently two schemes for managing pipelines:
James E. Blaircdd00072012-06-08 19:17:28 -0700165
Clark Boylan00635dc2012-09-19 14:03:08 -0700166 *IndependentPipelineManager*
167 Every event in this pipeline should be treated as independent of
168 other events in the pipeline. This is appropriate when the order of
169 events in the pipeline doesn't matter because the results of the
170 actions this pipeline performs can not affect other events in the
171 pipeline. For example, when a change is first uploaded for review,
James E. Blaircdd00072012-06-08 19:17:28 -0700172 you may want to run tests on that change to provide early feedback
173 to reviewers. At the end of the tests, the change is not going to
174 be merged, so it is safe to run these tests in parallel without
Clark Boylan00635dc2012-09-19 14:03:08 -0700175 regard to any other changes in the pipeline. They are independent.
James E. Blaircdd00072012-06-08 19:17:28 -0700176
Clark Boylan00635dc2012-09-19 14:03:08 -0700177 Another type of pipeline that is independent is a post-merge
178 pipeline. In that case, the changes have already merged, so the
179 results can not affect any other events in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700180
Clark Boylan00635dc2012-09-19 14:03:08 -0700181 *DependentPipelineManager*
182 The dependent pipeline manager is designed for gating. It ensures
James E. Blaircdd00072012-06-08 19:17:28 -0700183 that every change is tested exactly as it is going to be merged
184 into the repository. An ideal gating system would test one change
185 at a time, applied to the tip of the repository, and only if that
186 change passed tests would it be merged. Then the next change in
187 line would be tested the same way. In order to achieve parallel
Clark Boylan00635dc2012-09-19 14:03:08 -0700188 testing of changes, the dependent pipeline manager performs
James E. Blaircdd00072012-06-08 19:17:28 -0700189 speculative execution on changes. It orders changes based on
Clark Boylan00635dc2012-09-19 14:03:08 -0700190 their entry into the pipeline. It begins testing all changes in
191 parallel, assuming that each change ahead in the pipeline will pass
James E. Blaircdd00072012-06-08 19:17:28 -0700192 its tests. If they all succeed, all the changes can be tested and
Clark Boylan00635dc2012-09-19 14:03:08 -0700193 merged in parallel. If a change near the front of the pipeline
194 fails its tests, each change behind it ignores whatever tests have
195 been completed and are tested again without the change in front.
196 This way gate tests may run in parallel but still be tested
197 correctly, exactly as they will appear in the repository when
198 merged.
James E. Blaircdd00072012-06-08 19:17:28 -0700199
Clark Boylan00635dc2012-09-19 14:03:08 -0700200 One important characteristic of the DependentPipelineManager is that
James E. Blaircdd00072012-06-08 19:17:28 -0700201 it analyzes the jobs that are triggered by different projects, and
202 if those projects have jobs in common, it treats those projects as
203 related, and they share a single virtual queue of changes. Thus,
204 if there is a job that performs integration testing on two
205 projects, those two projects will automatically share a virtual
206 change queue. If a third project does not invoke that job, it
Clark Boylan00635dc2012-09-19 14:03:08 -0700207 will be part of a separate virtual change queue, and changes to
208 it will not depend on changes to the first two jobs.
James E. Blaircdd00072012-06-08 19:17:28 -0700209
210 For more detail on the theory and operation of Zuul's
Clark Boylan00635dc2012-09-19 14:03:08 -0700211 DependentPipelineManager, see: :doc:`gating`.
James E. Blaircdd00072012-06-08 19:17:28 -0700212
213**trigger**
Clark Boylan00635dc2012-09-19 14:03:08 -0700214 This describes what Gerrit events should be placed in the pipeline.
James E. Blaircdd00072012-06-08 19:17:28 -0700215 Triggers are not exclusive -- matching events may be placed in
Clark Boylan00635dc2012-09-19 14:03:08 -0700216 multiple pipelines, and they will behave independently in each of the
217 pipelines they match. Multiple triggers may be listed. Further
James E. Blaircdd00072012-06-08 19:17:28 -0700218 parameters describe the kind of events that match:
219
220 *event*
221 The event name from gerrit. Examples: ``patchset-created``,
222 ``comment-added``, ``ref-updated``. This field is treated as a
223 regular expression.
224
225 *branch*
226 The branch associated with the event. Example: ``master``. This
227 field is treated as a regular expression, and multiple branches may
228 be listed.
229
230 *ref*
231 On ref-updated events, the branch parameter is not used, instead the
232 ref is provided. Currently Gerrit has the somewhat idiosyncratic
233 behavior of specifying bare refs for branch names (e.g., ``master``),
234 but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
235 Zuul matches what you put here exactly against what Gerrit
236 provides. This field is treated as a regular expression, and
237 multiple refs may be listed.
238
239 *approval*
240 This is only used for ``comment-added`` events. It only matches if
241 the event has a matching approval associated with it. Example:
242 ``code-review: 2`` matches a ``+2`` vote on the code review category.
243 Multiple approvals may be listed.
244
Clark Boylanb9bcb402012-06-29 17:44:05 -0700245 *comment_filter*
246 This is only used for ``comment-added`` events. It accepts a list of
247 regexes that are searched for in the comment string. If any of these
248 regexes matches a portion of the comment string the trigger is
249 matched. ``comment_filter: retrigger`` will match when comments
250 containing 'retrigger' somewhere in the comment text are added to a
251 change.
252
James E. Blaircdd00072012-06-08 19:17:28 -0700253**success**
254 Describes what Zuul should do if all the jobs complete successfully.
255 This section is optional; if it is omitted, Zuul will run jobs and
256 do nothing on success; it will not even report a message to Gerrit.
257 If the section is present, it will leave a message on the Gerrit
258 review. Each additional argument is assumed to be an argument to
259 ``gerrit review``, with the boolean value of ``true`` simply
260 indicating that the argument should be present without following it
261 with a value. For example, ``verified: 1`` becomes ``gerrit
262 review --verified 1`` and ``submit: true`` becomes ``gerrit review
263 --submit``.
264
265**failure**
266 Uses the same syntax as **success**, but describes what Zuul should
267 do if at least one job fails.
James E. Blairdc253862012-06-13 17:12:42 -0700268
269**start**
270 Uses the same syntax as **success**, but describes what Zuul should
Clark Boylan00635dc2012-09-19 14:03:08 -0700271 do when a change is added to the pipeline manager. This can be used,
James E. Blairdc253862012-06-13 17:12:42 -0700272 for example, to reset the value of the Verified review category.
James E. Blaircdd00072012-06-08 19:17:28 -0700273
Clark Boylan00635dc2012-09-19 14:03:08 -0700274Some example pipeline configurations are included in the sample layout
275file. The first is called a *check* pipeline::
James E. Blaircdd00072012-06-08 19:17:28 -0700276
277 - name: check
Clark Boylan00635dc2012-09-19 14:03:08 -0700278 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700279 trigger:
280 - event: patchset-created
281 success:
282 verified: 1
283 failure:
284 verified: -1
285
286This will trigger jobs each time a new patchset (or change) is
287uploaded to Gerrit, and report +/-1 values to Gerrit in the
288``verified`` review category. ::
289
290 - name: gate
Clark Boylan00635dc2012-09-19 14:03:08 -0700291 manager: DependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700292 trigger:
293 - event: comment-added
294 approval:
295 - approved: 1
296 success:
297 verified: 2
298 submit: true
299 failure:
300 verified: -2
301
302This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the
303``approved`` review category in Gerrit (a non-standard category).
304Changes will be tested in such a way as to guarantee that they will be
305merged exactly as tested, though that will happen in parallel by
306creating a virtual queue of dependent changes and performing
307speculative execution of jobs. ::
308
309 - name: post
Clark Boylan00635dc2012-09-19 14:03:08 -0700310 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700311 trigger:
312 - event: ref-updated
313 ref: ^(?!refs/).*$
314
315This will trigger jobs whenever a change is merged to a named branch
316(e.g., ``master``). No output will be reported to Gerrit. This is
317useful for side effects such as creating per-commit tarballs. ::
318
319 - name: silent
Clark Boylan00635dc2012-09-19 14:03:08 -0700320 manager: IndependentPipelineManager
James E. Blaircdd00072012-06-08 19:17:28 -0700321 trigger:
322 - event: patchset-created
323
324This also triggers jobs when changes are uploaded to Gerrit, but no
325results are reported to Gerrit. This is useful for jobs that are in
Antoine Mussoce333842012-10-16 14:42:35 +0200326development and not yet ready to be presented to developers. ::
327
328 pipelines:
329 - name: post-merge
330 manager: IndependentPipelineManager
331 trigger:
332 - event: change-merged
333 success:
334 force-message: True
335 failure:
336 force-message: True
337
338The ``change-merged`` events happen when a change has been merged in the git
339repository. The change is thus closed and Gerrit will not accept modifications
340to the review scoring such as ``code-review`` or ``verified``. By using the
341``force-message: True`` parameter, Zuul will pass ``--force-message`` to the
342``gerrit review`` command, thus making sure the message is actually
343sent back to Gerrit regardless of approval scores.
344That kind of pipeline is nice to run regression or performance tests.
345
346.. note::
347 The ``change-merged`` event does not include the commit sha1 which can be
348 hazardous, it would let you report back to Gerrit though. If you were to
349 build a tarball for a specific commit, you should consider insteading using
350 the ``ref-updated`` event which does include the commit sha1 (but lack the
351 Gerrit change number).
James E. Blaircdd00072012-06-08 19:17:28 -0700352
353Jobs
354""""
355
356The jobs section is optional, and can be used to set attributes of
357jobs that are independent of their association with a project. For
358example, if a job should return a customized message on failure, that
359may be specified here. Otherwise, Zuul does not need to be told about
360each job as it builds a list from the project specification.
361
362**name**
363 The name of the job. This field is treated as a regular expression
364 and will be applied to each job that matches.
365
James E. Blaire5a847f2012-07-10 15:29:14 -0700366**failure-message (optional)**
367 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700368
James E. Blaire5a847f2012-07-10 15:29:14 -0700369**success-message (optional)**
370 The message that should be reported to Gerrit if the job fails.
James E. Blaircdd00072012-06-08 19:17:28 -0700371
James E. Blair222d4982012-07-16 09:31:19 -0700372**hold-following-changes (optional)**
373 This is a boolean that indicates that changes that follow this
Clark Boylan00635dc2012-09-19 14:03:08 -0700374 change in a dependent change pipeline should wait until this job
James E. Blair222d4982012-07-16 09:31:19 -0700375 succeeds before launching. If this is applied to a very short job
376 that can predict whether longer jobs will fail early, this can be
377 used to reduce the number of jobs that Zuul will launch and
378 ultimately have to cancel. In that case, a small amount of
379 paralellization of jobs is traded for more efficient use of testing
380 resources. On the other hand, to apply this to a long running job
381 would largely defeat the parallelization of dependent change testing
382 that is the main feature of Zuul. The default is False.
383
James E. Blaire5a847f2012-07-10 15:29:14 -0700384**branch (optional)**
James E. Blaircdd00072012-06-08 19:17:28 -0700385 This job should only be run on matching branches. This field is
386 treated as a regular expression and multiple branches may be
387 listed.
388
James E. Blaire5a847f2012-07-10 15:29:14 -0700389**parameter-function (optional)**
390 Specifies a function that should be applied to the parameters before
391 the job is launched. The function should be defined in a python file
392 included with the :ref:`includes` directive. The function
393 should have the following signature:
394
395 .. function:: parameters(change, parameters)
396
397 Manipulate the parameters passed to a job before a build is
398 launched. The ``parameters`` dictionary will already contain the
399 standard Zuul job parameters, and is expected to be modified
400 in-place.
401
402 :param change: the current change
403 :type change: zuul.model.Change
404 :param parameters: parameters to be passed to the job
405 :type parameters: dict
406
James E. Blaircdd00072012-06-08 19:17:28 -0700407Here is an example of setting the failure message for jobs that check
408whether a change merges cleanly::
409
410 - name: ^.*-merge$
411 failure-message: This change was unable to be automatically merged
412 with the current state of the repository. Please rebase your
413 change and upload a new patchset.
414
415Projects
416""""""""
417
Clark Boylan00635dc2012-09-19 14:03:08 -0700418The projects section indicates what jobs should be run in each pipeline
James E. Blaircdd00072012-06-08 19:17:28 -0700419for events associated with each project. It contains a list of
420projects. Here is an example::
421
422 - name: example/project
423 check:
424 - project-merge:
425 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700426 - project-pep8
427 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700428 gate:
429 - project-merge:
430 - project-unittest
Clark Boylan00635dc2012-09-19 14:03:08 -0700431 - project-pep8
432 - project-pyflakes
James E. Blaircdd00072012-06-08 19:17:28 -0700433 post:
434 - project-publish
435
436**name**
437 The name of the project (as known by Gerrit).
438
Clark Boylan00635dc2012-09-19 14:03:08 -0700439This is followed by a section for each of the pipelines defined above.
440Pipelines may be omitted if no jobs should run for this project in a
441given pipeline. Within the pipeline section, the jobs that should be
James E. Blaircdd00072012-06-08 19:17:28 -0700442executed are listed. If a job is entered as a dictionary key, then
443jobs contained within that key are only executed if the key job
444succeeds. In the above example, project-unittest, project-pep8, and
445project-pyflakes are only executed if project-merge succeeds. This
446can help avoid running unnecessary jobs.
447
Antoine Mussofec5c7a2012-09-22 12:32:37 +0200448.. 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 -0700449
450
451logging.conf
452~~~~~~~~~~~~
453This file is optional. If provided, it should be a standard
454:mod:`logging.config` module configuration file. If not present, Zuul will
455output all log messages of DEBUG level or higher to the console.
456
457Starting Zuul
458-------------
459
460To start Zuul, run **zuul-server**::
461
462 usage: zuul-server [-h] [-c CONFIG] [-d]
463
464 Project gating system.
465
466 optional arguments:
467 -h, --help show this help message and exit
468 -c CONFIG specify the config file
469 -d do not run as a daemon
470
471You may want to use the ``-d`` argument while you are initially setting
472up Zuul so you can detect any configuration errors quickly. Under
473normal operation, omit ``-d`` and let Zuul run as a daemon.
474
475If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will
476stop executing new jobs, wait until all executing jobs are finished,
477reload its configuration, and resume. Any values in any of the
478configuration files may be changed, except the location of Zuul's PID
479file (a change to that will be ignored until Zuul is restarted).