blob: 5ca86778edde30cd3feade86b4f8153b2d87d9c2 [file] [log] [blame]
James E. Blair1de8d402017-05-07 17:08:04 -07001:title: Project Configuration
2
3.. _project-config:
4
5Project Configuration
6=====================
7
8The following sections describe the main part of Zuul's configuration.
9All of what follows is found within files inside of the repositories
10that Zuul manages.
11
12Security Contexts
13-----------------
14
15When a system administrator configures Zuul to operate on a project,
16they specify one of two security contexts for that project. A
17*config-project* is one which is primarily tasked with holding
18configuration information and job content for Zuul. Jobs which are
19defined in a *config-project* are run with elevated privileges, and
20all Zuul configuration items are available for use. It is expected
21that changes to *config-projects* will undergo careful scrutiny before
22being merged.
23
24An *untrusted-project* is a project whose primary focus is not to
25operate Zuul, but rather it is one of the projects being tested or
26deployed. The Zuul configuration language available to these projects
27is somewhat restricted (as detailed in individual section below), and
28jobs defined in these projects run in a restricted execution
29environment since they may be operating on changes which have not yet
30undergone review.
31
32Configuration Loading
33---------------------
34
35When Zuul starts, it examines all of the git repositories which are
James E. Blaireff5a9d2017-06-20 00:00:37 -070036specified by the system administrator in :ref:`tenant-config` and searches
Tristan Cacqueray4a015832017-07-11 05:18:14 +000037for files in the root of each repository. Zuul looks first for a file named
38`zuul.yaml` or a directory named `zuul.d`, and if they are not found,
39`.zuul.yaml` or `.zuul.d` (with a leading dot). In the case of an
40*untrusted-project*, the configuration from every branch is included,
41however, in the case of a *config-project*, only the `master` branch is
42examined.
James E. Blair1de8d402017-05-07 17:08:04 -070043
44When a change is proposed to one of these files in an
45*untrusted-project*, the configuration proposed in the change is
46merged into the running configuration so that any changes to Zuul's
47configuration are self-testing as part of that change. If there is a
48configuration error, no jobs will be run and the error will be
49reported by any applicable pipelines. In the case of a change to a
50*config-project*, the new configuration is parsed and examined for
51errors, but the new configuration is not used in testing the change.
52This is because configuration in *config-projects* is able to access
53elevated privileges and should always be reviewed before being merged.
54
55As soon as a change containing a Zuul configuration change merges to
56any Zuul-managed repository, the new configuration takes effect
57immediately.
58
59Configuration Items
60-------------------
61
62The `zuul.yaml` and `.zuul.yaml` configuration files are
63YAML-formatted and are structured as a series of items, each of which
64is described below.
65
Tristan Cacqueray4a015832017-07-11 05:18:14 +000066In the case of a `zuul.d` directory, Zuul recurses the directory and extends
67the configuration using all the .yaml files in the sorted path order.
68For example, to keep job's variants in a separate file, it needs to be loaded
69after the main entries, for example using number prefixes in file's names::
70
71* zuul.d/pipelines.yaml
72* zuul.d/projects.yaml
73* zuul.d/01_jobs.yaml
74* zuul.d/02_jobs-variants.yaml
75
James E. Blair1de8d402017-05-07 17:08:04 -070076.. _pipeline:
77
78Pipeline
79~~~~~~~~
80
81A pipeline describes a workflow operation in Zuul. It associates jobs
82for a given project with triggering and reporting events.
83
84Its flexible configuration allows for characterizing any number of
85workflows, and by specifying each as a named configuration, makes it
86easy to apply similar workflow operations to projects or groups of
87projects.
88
89By way of example, one of the primary uses of Zuul is to perform
90project gating. To do so, one can create a *gate* pipeline which
91tells Zuul that when a certain event (such as approval by a code
92reviewer) occurs, the corresponding change or pull request should be
93enqueued into the pipeline. When that happens, the jobs which have
94been configured to run for that project in the *gate* pipeline are
95run, and when they complete, the pipeline reports the results to the
96user.
97
98Pipeline configuration items may only appear in *config-projects*.
99
100Generally, a Zuul administrator would define a small number of
101pipelines which represent the workflow processes used in their
102environment. Each project can then be added to the available
103pipelines as appropriate.
104
105Here is an example *check* pipeline, which runs whenever a new
106patchset is created in Gerrit. If the associated jobs all report
107success, the pipeline reports back to Gerrit with a *Verified* vote of
108+1, or if at least one of them fails, a -1::
109
110 - pipeline:
James E. Blaira8387ec2017-07-05 14:00:12 -0700111 name: check
James E. Blair1de8d402017-05-07 17:08:04 -0700112 manager: independent
113 trigger:
114 my_gerrit:
115 - event: patchset-created
116 success:
117 my_gerrit:
Tobias Henkelea98a192017-05-29 21:15:17 +0200118 Verified: 1
James E. Blair1de8d402017-05-07 17:08:04 -0700119 failure:
120 my_gerrit
Tobias Henkelea98a192017-05-29 21:15:17 +0200121 Verified: -1
James E. Blair1de8d402017-05-07 17:08:04 -0700122
James E. Blaireff5a9d2017-06-20 00:00:37 -0700123.. TODO: See TODO for more annotated examples of common pipeline configurations.
James E. Blair1de8d402017-05-07 17:08:04 -0700124
James E. Blair94375912017-07-28 17:20:27 -0700125.. attr:: pipeline
James E. Blair7145c582017-07-26 13:30:39 -0700126
James E. Blair9fd98ab2017-07-26 14:15:26 -0700127 The attributes available on a pipeline are as follows (all are
128 optional unless otherwise specified):
James E. Blair1de8d402017-05-07 17:08:04 -0700129
James E. Blair94375912017-07-28 17:20:27 -0700130 .. attr:: name
James E. Blair9fd98ab2017-07-26 14:15:26 -0700131 :required:
James E. Blair1de8d402017-05-07 17:08:04 -0700132
James E. Blair9fd98ab2017-07-26 14:15:26 -0700133 This is used later in the project definition to indicate what jobs
134 should be run for events in the pipeline.
James E. Blair1de8d402017-05-07 17:08:04 -0700135
James E. Blair94375912017-07-28 17:20:27 -0700136 .. attr:: manager
James E. Blair9fd98ab2017-07-26 14:15:26 -0700137 :required:
James E. Blaireff5a9d2017-06-20 00:00:37 -0700138
James E. Blair9fd98ab2017-07-26 14:15:26 -0700139 There are currently two schemes for managing pipelines:
James E. Blair1de8d402017-05-07 17:08:04 -0700140
James E. Blair9fd98ab2017-07-26 14:15:26 -0700141 .. zuul:value:: independent
James E. Blaireff5a9d2017-06-20 00:00:37 -0700142
James E. Blair9fd98ab2017-07-26 14:15:26 -0700143 Every event in this pipeline should be treated as independent
144 of other events in the pipeline. This is appropriate when
145 the order of events in the pipeline doesn't matter because
146 the results of the actions this pipeline performs can not
147 affect other events in the pipeline. For example, when a
148 change is first uploaded for review, you may want to run
149 tests on that change to provide early feedback to reviewers.
150 At the end of the tests, the change is not going to be
151 merged, so it is safe to run these tests in parallel without
152 regard to any other changes in the pipeline. They are
153 independent.
James E. Blair1de8d402017-05-07 17:08:04 -0700154
James E. Blair9fd98ab2017-07-26 14:15:26 -0700155 Another type of pipeline that is independent is a post-merge
156 pipeline. In that case, the changes have already merged, so
157 the results can not affect any other events in the pipeline.
James E. Blair1761e862017-07-25 16:15:47 -0700158
James E. Blair9fd98ab2017-07-26 14:15:26 -0700159 .. zuul:value:: dependent
James E. Blair1761e862017-07-25 16:15:47 -0700160
James E. Blair9fd98ab2017-07-26 14:15:26 -0700161 The dependent pipeline manager is designed for gating. It
162 ensures that every change is tested exactly as it is going to
163 be merged into the repository. An ideal gating system would
164 test one change at a time, applied to the tip of the
165 repository, and only if that change passed tests would it be
166 merged. Then the next change in line would be tested the
167 same way. In order to achieve parallel testing of changes,
168 the dependent pipeline manager performs speculative execution
169 on changes. It orders changes based on their entry into the
170 pipeline. It begins testing all changes in parallel,
171 assuming that each change ahead in the pipeline will pass its
172 tests. If they all succeed, all the changes can be tested
173 and merged in parallel. If a change near the front of the
174 pipeline fails its tests, each change behind it ignores
175 whatever tests have been completed and are tested again
176 without the change in front. This way gate tests may run in
177 parallel but still be tested correctly, exactly as they will
178 appear in the repository when merged.
James E. Blair1761e862017-07-25 16:15:47 -0700179
James E. Blair9fd98ab2017-07-26 14:15:26 -0700180 For more detail on the theory and operation of Zuul's
181 dependent pipeline manager, see: :doc:`gating`.
James E. Blair1de8d402017-05-07 17:08:04 -0700182
James E. Blair94375912017-07-28 17:20:27 -0700183 .. attr:: allow-secrets
James E. Blairf17aa9c2017-07-05 13:21:23 -0700184
James E. Blair9fd98ab2017-07-26 14:15:26 -0700185 This is a boolean which can be used to prevent jobs which
186 require secrets from running in this pipeline. Some pipelines
187 run on proposed changes and therefore execute code which has not
188 yet been reviewed. In such a case, allowing a job to use a
189 secret could result in that secret being exposed. The default
190 is False, meaning that in order to run jobs with secrets, this
191 must be explicitly enabled on each Pipeline where that is safe.
James E. Blairf17aa9c2017-07-05 13:21:23 -0700192
James E. Blair9fd98ab2017-07-26 14:15:26 -0700193 For more information, see :ref:`secret`.
James E. Blair1de8d402017-05-07 17:08:04 -0700194
James E. Blair94375912017-07-28 17:20:27 -0700195 .. attr:: description
James E. Blair1de8d402017-05-07 17:08:04 -0700196
James E. Blair9fd98ab2017-07-26 14:15:26 -0700197 This field may be used to provide a textual description of the
198 pipeline. It may appear in the status page or in documentation.
James E. Blair1de8d402017-05-07 17:08:04 -0700199
James E. Blair94375912017-07-28 17:20:27 -0700200 .. attr:: success-message
James E. Blair1de8d402017-05-07 17:08:04 -0700201
James E. Blair9fd98ab2017-07-26 14:15:26 -0700202 The introductory text in reports when all the voting jobs are
203 successful. Defaults to "Build successful."
James E. Blair1de8d402017-05-07 17:08:04 -0700204
James E. Blair94375912017-07-28 17:20:27 -0700205 .. attr:: failure-message
James E. Blair1de8d402017-05-07 17:08:04 -0700206
James E. Blair9fd98ab2017-07-26 14:15:26 -0700207 The introductory text in reports when at least one voting job
208 fails. Defaults to "Build failed."
James E. Blair1de8d402017-05-07 17:08:04 -0700209
James E. Blair94375912017-07-28 17:20:27 -0700210 .. attr:: merge-failure-message
James E. Blair1de8d402017-05-07 17:08:04 -0700211
James E. Blair9fd98ab2017-07-26 14:15:26 -0700212 The introductory text in the message reported when a change
213 fails to merge with the current state of the repository.
214 Defaults to "Merge failed."
James E. Blair1de8d402017-05-07 17:08:04 -0700215
James E. Blair94375912017-07-28 17:20:27 -0700216 .. attr:: footer-message
James E. Blair1de8d402017-05-07 17:08:04 -0700217
James E. Blair9fd98ab2017-07-26 14:15:26 -0700218 Supplies additional information after test results. Useful for
219 adding information about the CI system such as debugging and
220 contact details.
James E. Blair1de8d402017-05-07 17:08:04 -0700221
James E. Blair94375912017-07-28 17:20:27 -0700222 .. attr:: trigger
James E. Blair1de8d402017-05-07 17:08:04 -0700223
James E. Blair9fd98ab2017-07-26 14:15:26 -0700224 At least one trigger source must be supplied for each pipeline.
225 Triggers are not exclusive -- matching events may be placed in
226 multiple pipelines, and they will behave independently in each
227 of the pipelines they match.
James E. Blair1de8d402017-05-07 17:08:04 -0700228
James E. Blair9fd98ab2017-07-26 14:15:26 -0700229 Triggers are loaded from their connection name. The driver type
230 of the connection will dictate which options are available. See
231 :ref:`drivers`.
James E. Blair1de8d402017-05-07 17:08:04 -0700232
James E. Blaird134c6d2017-07-26 16:09:34 -0700233 .. _pipeline-require:
234
James E. Blair94375912017-07-28 17:20:27 -0700235 .. attr:: require
James E. Blair1de8d402017-05-07 17:08:04 -0700236
James E. Blaird134c6d2017-07-26 16:09:34 -0700237 If this section is present, it establishes pre-requisites for
James E. Blair9fd98ab2017-07-26 14:15:26 -0700238 any kind of item entering the Pipeline. Regardless of how the
239 item is to be enqueued (via any trigger or automatic dependency
240 resolution), the conditions specified here must be met or the
James E. Blaird134c6d2017-07-26 16:09:34 -0700241 item will not be enqueued. These requirements may vary
242 depending on the source of the item being enqueued.
James E. Blair1de8d402017-05-07 17:08:04 -0700243
James E. Blaird134c6d2017-07-26 16:09:34 -0700244 Requirements are loaded from their connection name. The driver
245 type of the connection will dictate which options are available.
246 See :ref:`drivers`.
James E. Blair1de8d402017-05-07 17:08:04 -0700247
James E. Blaird134c6d2017-07-26 16:09:34 -0700248 .. _pipeline-reject:
James E. Blair1de8d402017-05-07 17:08:04 -0700249
James E. Blair94375912017-07-28 17:20:27 -0700250 .. attr:: reject
James E. Blair1de8d402017-05-07 17:08:04 -0700251
James E. Blair9fd98ab2017-07-26 14:15:26 -0700252 If this section is present, it establishes pre-requisites that
253 can block an item from being enqueued. It can be considered a
254 negative version of **require**.
James E. Blair1de8d402017-05-07 17:08:04 -0700255
James E. Blaird134c6d2017-07-26 16:09:34 -0700256 Requirements are loaded from their connection name. The driver
257 type of the connection will dictate which options are available.
258 See :ref:`drivers`.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700259
James E. Blair94375912017-07-28 17:20:27 -0700260 .. attr:: dequeue-on-new-patchset
James E. Blair9fd98ab2017-07-26 14:15:26 -0700261
262 Normally, if a new patchset is uploaded to a change that is in a
263 pipeline, the existing entry in the pipeline will be removed
264 (with jobs canceled and any dependent changes that can no longer
265 merge as well. To suppress this behavior (and allow jobs to
266 continue running), set this to ``false``. Default: ``true``.
267
James E. Blair94375912017-07-28 17:20:27 -0700268 .. attr:: ignore-dependencies
James E. Blair9fd98ab2017-07-26 14:15:26 -0700269
270 In any kind of pipeline (dependent or independent), Zuul will
271 attempt to enqueue all dependencies ahead of the current change
272 so that they are tested together (independent pipelines report
273 the results of each change regardless of the results of changes
274 ahead). To ignore dependencies completely in an independent
275 pipeline, set this to ``true``. This option is ignored by
276 dependent pipelines. The default is: ``false``.
277
James E. Blair94375912017-07-28 17:20:27 -0700278 .. attr:: precedence
James E. Blair9fd98ab2017-07-26 14:15:26 -0700279
280 Indicates how the build scheduler should prioritize jobs for
281 different pipelines. Each pipeline may have one precedence,
282 jobs for pipelines with a higher precedence will be run before
283 ones with lower. The value should be one of ``high``,
284 ``normal``, or ``low``. Default: ``normal``.
285
286 The following options configure *reporters*. Reporters are
287 complementary to triggers; where a trigger is an event on a
288 connection which causes Zuul to enqueue an item, a reporter is the
289 action performed on a connection when an item is dequeued after its
290 jobs complete. The actual syntax for a reporter is defined by the
291 driver which implements it. See :ref:`drivers` for more
292 information.
293
James E. Blair94375912017-07-28 17:20:27 -0700294 .. attr:: success
James E. Blair9fd98ab2017-07-26 14:15:26 -0700295
296 Describes where Zuul should report to if all the jobs complete
297 successfully. This section is optional; if it is omitted, Zuul
298 will run jobs and do nothing on success -- it will not report at
299 all. If the section is present, the listed reporters will be
300 asked to report on the jobs. The reporters are listed by their
301 connection name. The options available depend on the driver for
302 the supplied connection.
303
James E. Blair94375912017-07-28 17:20:27 -0700304 .. attr:: failure
James E. Blair9fd98ab2017-07-26 14:15:26 -0700305
306 These reporters describe what Zuul should do if at least one job
307 fails.
308
James E. Blair94375912017-07-28 17:20:27 -0700309 .. attr:: merge-failure
James E. Blair9fd98ab2017-07-26 14:15:26 -0700310
311 These reporters describe what Zuul should do if it is unable to
312 merge in the patchset. If no merge-failure reporters are listed
313 then the ``failure`` reporters will be used to notify of
314 unsuccessful merges.
315
James E. Blair94375912017-07-28 17:20:27 -0700316 .. attr:: start
James E. Blair9fd98ab2017-07-26 14:15:26 -0700317
318 These reporters describe what Zuul should do when a change is
319 added to the pipeline. This can be used, for example, to reset
320 a previously reported result.
321
James E. Blair94375912017-07-28 17:20:27 -0700322 .. attr:: disabled
James E. Blair9fd98ab2017-07-26 14:15:26 -0700323
324 These reporters describe what Zuul should do when a pipeline is
325 disabled. See ``disable-after-consecutive-failures``.
326
327 The following options can be used to alter Zuul's behavior to
328 mitigate situations in which jobs are failing frequently (perhaps
329 due to a problem with an external dependency, or unusually high
330 non-deterministic test failures).
331
James E. Blair94375912017-07-28 17:20:27 -0700332 .. attr:: disable-after-consecutive-failures
James E. Blair9fd98ab2017-07-26 14:15:26 -0700333
334 If set, a pipeline can enter a ''disabled'' state if too many
335 changes in a row fail. When this value is exceeded the pipeline
336 will stop reporting to any of the ``success``, ``failure`` or
337 ``merge-failure`` reporters and instead only report to the
338 ``disabled`` reporters. (No ``start`` reports are made when a
339 pipeline is disabled).
340
James E. Blair94375912017-07-28 17:20:27 -0700341 .. attr:: window
James E. Blair9fd98ab2017-07-26 14:15:26 -0700342
343 Dependent pipeline managers only. Zuul can rate limit dependent
344 pipelines in a manner similar to TCP flow control. Jobs are
345 only started for items in the queue if they are within the
346 actionable window for the pipeline. The initial length of this
347 window is configurable with this value. The value given should
348 be a positive integer value. A value of ``0`` disables rate
349 limiting on the DependentPipelineManager. Default: ``20``.
350
James E. Blair94375912017-07-28 17:20:27 -0700351 .. attr:: window-floor
James E. Blair9fd98ab2017-07-26 14:15:26 -0700352
353 Dependent pipeline managers only. This is the minimum value for
354 the window described above. Should be a positive non zero
355 integer value. Default: ``3``.
356
James E. Blair94375912017-07-28 17:20:27 -0700357 .. attr:: window-increase-type
James E. Blair9fd98ab2017-07-26 14:15:26 -0700358
359 Dependent pipeline managers only. This value describes how the
360 window should grow when changes are successfully merged by
361 zuul. A value of ``linear`` indicates that
362 ``window-increase-factor`` should be added to the previous
363 window value. A value of ``exponential`` indicates that
364 ``window-increase-factor`` should be multiplied against the
365 previous window value and the result will become the window
366 size. Default: ``linear``.
367
James E. Blair94375912017-07-28 17:20:27 -0700368 .. attr:: window-increase-factor
James E. Blair9fd98ab2017-07-26 14:15:26 -0700369
370 Dependent pipeline managers only. The value to be added or
371 multiplied against the previous window value to determine the
372 new window after successful change merges. Default: ``1``.
373
James E. Blair94375912017-07-28 17:20:27 -0700374 .. attr:: window-decrease-type
James E. Blair9fd98ab2017-07-26 14:15:26 -0700375
376 Dependent pipeline managers only. This value describes how the
377 window should shrink when changes are not able to be merged by
378 Zuul. A value of ``linear`` indicates that
379 ``window-decrease-factor`` should be subtracted from the
380 previous window value. A value of ``exponential`` indicates that
381 ``window-decrease-factor`` should be divided against the
382 previous window value and the result will become the window
383 size. Default: ``exponential``.
384
James E. Blair94375912017-07-28 17:20:27 -0700385 .. attr:: window-decrease-factor
James E. Blair9fd98ab2017-07-26 14:15:26 -0700386
387 Dependent pipline managers only. The value to be subtracted or
388 divided against the previous window value to determine the new
389 window after unsuccessful change merges. Default: ``2``.
James E. Blair1de8d402017-05-07 17:08:04 -0700390
391
392.. _job:
393
394Job
395~~~
396
397A job is a unit of work performed by Zuul on an item enqueued into a
398pipeline. Items may run any number of jobs (which may depend on each
399other). Each job is an invocation of an Ansible playbook with a
400specific inventory of hosts. The actual tasks that are run by the job
401appear in the playbook for that job while the attributes that appear in the
402Zuul configuration specify information about when, where, and how the
403job should be run.
404
405Jobs in Zuul support inheritance. Any job may specify a single parent
406job, and any attributes not set on the child job are collected from
407the parent job. In this way, a configuration structure may be built
408starting with very basic jobs which describe characteristics that all
409jobs on the system should have, progressing through stages of
410specialization before arriving at a particular job. A job may inherit
411from any other job in any project (however, if the other job is marked
412as `final`, some attributes may not be overidden).
413
414Jobs also support a concept called variance. The first time a job
415definition appears is called the reference definition of the job.
416Subsequent job definitions with the same name are called variants.
417These may have different selection criteria which indicate to Zuul
418that, for instance, the job should behave differently on a different
419git branch. Unlike inheritance, all job variants must be defined in
420the same project.
421
422When Zuul decides to run a job, it performs a process known as
423freezing the job. Because any number of job variants may be
424applicable, Zuul collects all of the matching variants and applies
425them in the order they appeared in the configuration. The resulting
426frozen job is built from attributes gathered from all of the
427matching variants. In this way, exactly what is run is dependent on
428the pipeline, project, branch, and content of the item.
429
430In addition to the job's main playbook, each job may specify one or
431more pre- and post-playbooks. These are run, in order, before and
432after (respectively) the main playbook. They may be used to set up
433and tear down resources needed by the main playbook. When combined
434with inheritance, they provide powerful tools for job construction. A
435job only has a single main playbook, and when inheriting from a
436parent, the child's main playbook overrides (or replaces) the
437parent's. However, the pre- and post-playbooks are appended and
438prepended in a nesting fashion. So if a parent job and child job both
439specified pre and post playbooks, the sequence of playbooks run would
440be:
441
442* parent pre-run playbook
443* child pre-run playbook
444* child playbook
445* child post-run playbook
446* parent post-run playbook
447
448Further inheritance would nest even deeper.
449
450Here is an example of two job definitions::
451
452 - job:
453 name: base
454 pre-run: copy-git-repos
455 post-run: copy-logs
456
457 - job:
458 name: run-tests
459 parent: base
460 nodes:
461 - name: test-node
James E. Blair9fd98ab2017-07-26 14:15:26 -0700462 image: fedora
James E. Blair1de8d402017-05-07 17:08:04 -0700463
464The following attributes are available on a job; all are optional
465unless otherwise specified:
466
467**name** (required)
468 The name of the job. By default, Zuul looks for a playbook with
469 this name to use as the main playbook for the job. This name is
470 also referenced later in a project pipeline configuration.
471
472**parent**
473 Specifies a job to inherit from. The parent job can be defined in
474 this or any other project. Any attributes not specified on a job
475 will be collected from its parent.
476
477**description**
478 A textual description of the job. Not currently used directly by
479 Zuul, but it is used by the zuul-sphinx extension to Sphinx to
480 auto-document Zuul jobs (in which case it is interpreted as
481 ReStructuredText.
482
483**success-message**
484 Normally when a job succeeds, the string "SUCCESS" is reported as
485 the result for the job. If set, this option may be used to supply a
486 different string. Default: "SUCCESS".
487
488**failure-message**
489 Normally when a job fails, the string "FAILURE" is reported as
490 the result for the job. If set, this option may be used to supply a
491 different string. Default: "FAILURE".
492
493**success-url**
James E. Blair88e79c02017-07-07 13:36:54 -0700494 When a job succeeds, this URL is reported along with the result. If
495 this value is not supplied, Zuul uses the content of the job
496 :ref:`return value <return_values>` **zuul.log_url**. This is
497 recommended as it allows the code which stores the URL to the job
498 artifacts to report exactly where they were stored. To override
499 this value, or if it is not set, supply an absolute URL in this
500 field. If a relative URL is supplied in this field, and
501 **zuul.log_url** is set, then the two will be combined to produce
502 the URL used for the report. This can be used to specify that
503 certain jobs should "deep link" into the stored job artifacts.
James E. Blair1de8d402017-05-07 17:08:04 -0700504 Default: none.
505
506**failure-url**
507 When a job fails, this URL is reported along with the result.
James E. Blair88e79c02017-07-07 13:36:54 -0700508 Otherwise behaves the same as **success-url**.
James E. Blair1de8d402017-05-07 17:08:04 -0700509
510**hold-following-changes**
511 In a dependent pipeline, this option may be used to indicate that no
512 jobs should start on any items which depend on the current item
513 until this job has completed successfully. This may be used to
514 conserve build resources, at the expense of inhibiting the
515 parallelization which speeds the processing of items in a dependent
516 pipeline. A boolean value, default: false.
517
518**voting**
519 Indicates whether the result of this job should be used in
520 determining the overall result of the item. A boolean value,
521 default: true.
522
523**semaphore**
524 The name of a :ref:`semaphore` which should be acquired and released
525 when the job begins and ends. If the semaphore is at maximum
526 capacity, then Zuul will wait until it can be acquired before
527 starting the job. Default: none.
528
529**tags**
530 Metadata about this job. Tags are units of information attached to
531 the job; they do not affect Zuul's behavior, but they can be used
532 within the job to characterize the job. For example, a job which
533 tests a certain subsystem could be tagged with the name of that
534 subsystem, and if the job's results are reported into a database,
535 then the results of all jobs affecting that subsystem could be
536 queried. This attribute is specified as a list of strings, and when
537 inheriting jobs or applying variants, tags accumulate in a set, so
538 the result is always a set of all the tags from all the jobs and
539 variants used in constructing the frozen job, with no duplication.
540 Default: none.
541
James E. Blaireff5a9d2017-06-20 00:00:37 -0700542**branches**
James E. Blair1de8d402017-05-07 17:08:04 -0700543 A regular expression (or list of regular expressions) which describe
544 on what branches a job should run (or in the case of variants: to
545 alter the behavior of a job for a certain branch).
546
547 If there is no job definition for a given job which matches the
548 branch of an item, then that job is not run for the item.
549 Otherwise, all of the job variants which match that branch (and any
550 other selection criteria) are used when freezing the job.
551
552 This example illustrates a job called *run-tests* which uses a
553 nodeset based on the current release of an operating system to
554 perform its tests, except when testing changes to the stable/2.0
555 branch, in which case it uses an older release::
556
557 - job:
558 name: run-tests
559 nodes: current-release
560
561 - job:
562 name: run-tests
563 branch: stable/2.0
564 nodes: old-release
565
566 In some cases, Zuul uses an implied value for the branch specifier
567 if none is supplied:
568
569 * For a job definition in a *config-project*, no implied branch
570 specifier is used. If no branch specifier appears, the job
571 applies to all branches.
572
573 * In the case of an *untrusted-project*, no implied branch specifier
574 is applied to the reference definition of a job. That is to say,
575 that if the first appearance of the job definition appears without
576 a branch specifier, then it will apply to all branches. Note that
577 when collecting its configuration, Zuul reads the `master` branch
578 of a given project first, then other branches in alphabetical
579 order.
580
581 * Any further job variants other than the reference definition in an
582 *untrusted-project* will, if they do not have a branch specifier,
583 will have an implied branch specifier for the current branch
584 applied.
585
586 This allows for the very simple and expected workflow where if a
587 project defines a job on the master branch with no branch specifier,
588 and then creates a new branch based on master, any changes to that
589 job definition within the new branch only affect that branch.
590
591**files**
592 This attribute indicates that the job should only run on changes
593 where the specified files are modified. This is a regular
594 expression or list of regular expressions. Default: none.
595
596**irrelevant-files**
597 This is a negative complement of `files`. It indicates that the job
598 should run unless *all* of the files changed match this list. In
599 other words, if the regular expression `docs/.*` is supplied, then
600 this job will not run if the only files changed are in the docs
601 directory. A regular expression or list of regular expressions.
602 Default: none.
603
604**auth**
605 Authentication information to be made available to the job. This is
606 a dictionary with two potential keys:
607
608 **inherit**
609 A boolean indicating that the authentication information referenced
610 by this job should be able to be inherited by child jobs. Normally
611 when a job inherits from another job, the auth section is not
612 included. This permits jobs to inherit the same basic structure and
613 playbook, but ensures that secret information is unable to be
614 exposed by a child job which may alter the job's behavior. If it is
615 safe for the contents of the authentication section to be used by
616 child jobs, set this to ``true``. Default: ``false``.
617
618 **secrets**
619 A list of secrets which may be used by the job. A :ref:`secret` is
620 a named collection of private information defined separately in the
621 configuration. The secrets that appear here must be defined in the
622 same project as this job definition.
623
624 In the future, other types of authentication information may be
625 added.
626
627**nodes**
628 A list of nodes which should be supplied to the job. This parameter
629 may be supplied either as a string, in which case it references a
630 :ref:`nodeset` definition which appears elsewhere in the
631 configuration, or a list, in which case it is interpreted in the
632 same way as a Nodeset definition (in essence, it is an anonymous
633 Node definition unique to this job). See the :ref:`nodeset`
634 reference for the syntax to use in that case.
635
636 If a job has an empty or no node definition, it will still run and
637 may be able to perform actions on the Zuul executor.
638
639**override-branch**
640 When Zuul runs jobs for a proposed change, it normally checks out
641 the branch associated with that change on every project present in
642 the job. If jobs are running on a ref (such as a branch tip or
643 tag), then that ref is normally checked out. This attribute is used
644 to override that behavior and indicate that this job should,
645 regardless of the branch for the queue item, use the indicated
646 branch instead. This can be used, for example, to run a previous
647 version of the software (from a stable maintenance branch) under
648 test even if the change being tested applies to a different branch
649 (this is only likely to be useful if there is some cross-branch
650 interaction with some component of the system being tested). See
651 also the project-specific **override-branch** attribute under
652 **required-projects** to apply this behavior to a subset of a job's
653 projects.
654
655**timeout**
656 The time in minutes that the job should be allowed to run before it
657 is automatically aborted and failure is reported. If no timeout is
658 supplied, the job may run indefinitely. Supplying a timeout is
659 highly recommended.
660
661**attempts**
662 When Zuul encounters an error running a job's pre-run playbook, Zuul
663 will stop and restart the job. Errors during the main or
664 post-run -playbook phase of a job are not affected by this parameter
665 (they are reported immediately). This parameter controls the number
666 of attempts to make before an error is reported. Default: 3.
667
668**pre-run**
Tobias Henkel2aade262017-07-12 16:09:06 +0200669 The name of a playbook or list of playbooks without file extension
670 to run before the main body of a job. The full path to the playbook
671 in the repo where the job is defined is expected.
James E. Blair1de8d402017-05-07 17:08:04 -0700672
673 When a job inherits from a parent, the child's pre-run playbooks are
674 run after the parent's. See :ref:`job` for more information.
675
676**post-run**
Tobias Henkel2aade262017-07-12 16:09:06 +0200677 The name of a playbook or list of playbooks without file extension
678 to run after the main body of a job. The full path to the playbook
679 in the repo where the job is defined is expected.
James E. Blair1de8d402017-05-07 17:08:04 -0700680
681 When a job inherits from a parent, the child's post-run playbooks
682 are run before the parent's. See :ref:`job` for more information.
683
684**run**
Tobias Henkel2aade262017-07-12 16:09:06 +0200685 The name of the main playbook for this job. This parameter is
686 not normally necessary, as it defaults to a playbook with the
687 same name as the job inside of the `playbooks/` directory (e.g.,
688 the `foo` job would default to `playbooks/foo`. However, if a
689 playbook with a different name is needed, it can be specified
690 here. The file extension is not required, but the full path
691 within the repo is. When a child inherits from a parent, a
692 playbook with the name of the child job is implicitly searched
693 first, before falling back on the playbook used by the parent
694 job (unless the child job specifies a ``run`` attribute, in which
695 case that value is used). Example::
696
697 run: playbooks/<name of the job>
James E. Blair1de8d402017-05-07 17:08:04 -0700698
699**roles**
700 A list of Ansible roles to prepare for the job. Because a job runs
701 an Ansible playbook, any roles which are used by the job must be
702 prepared and installed by Zuul before the job begins. This value is
703 a list of dictionaries, each of which indicates one of two types of
704 roles: a Galaxy role, which is simply a role that is installed from
705 Ansible Galaxy, or a Zuul role, which is a role provided by a
706 project managed by Zuul. Zuul roles are able to benefit from
James E. Blair74a82cf2017-07-12 17:23:08 -0700707 speculative merging and cross-project dependencies when used by
James E. Blair4eec8282017-07-12 17:33:26 -0700708 playbooks in untrusted projects. Roles are added to the Ansible
709 role path in the order they appear on the job -- roles earlier in
710 the list will take precedence over those which follow.
James E. Blair74a82cf2017-07-12 17:23:08 -0700711
712 In the case of job inheritance or variance, the roles used for each
713 of the playbooks run by the job will be only those which were
714 defined along with that playbook. If a child job inherits from a
715 parent which defines a pre and post playbook, then the pre and post
716 playbooks it inherits from the parent job will run only with the
717 roles that were defined on the parent. If the child adds its own
718 pre and post playbooks, then any roles added by the child will be
719 available to the child's playbooks. This is so that a job which
720 inherits from a parent does not inadvertantly alter the behavior of
James E. Blair4eec8282017-07-12 17:33:26 -0700721 the parent's playbooks by the addition of conflicting roles. Roles
722 added by a child will appear before those it inherits from its
723 parent.
James E. Blair1de8d402017-05-07 17:08:04 -0700724
725 A project which supplies a role may be structured in one of two
726 configurations: a bare role (in which the role exists at the root of
727 the project), or a contained role (in which the role exists within
728 the `roles/` directory of the project, perhaps along with other
729 roles). In the case of a contained role, the `roles/` directory of
730 the project is added to the role search path. In the case of a bare
731 role, the project itself is added to the role search path. In case
732 the name of the project is not the name under which the role should
733 be installed (and therefore referenced from Ansible), the `name`
734 attribute may be used to specify an alternate.
735
James E. Blairbb94dfa2017-07-11 07:45:19 -0700736 A job automatically has the project in which it is defined added to
737 the roles path if that project appears to contain a role or `roles/`
738 directory. By default, the project is added to the path under its
739 own name, however, that may be changed by explicitly listing the
740 project in the roles list in the usual way.
741
James E. Blaireff5a9d2017-06-20 00:00:37 -0700742 .. note:: galaxy roles are not yet implemented
743
James E. Blair1de8d402017-05-07 17:08:04 -0700744 **galaxy**
745 The name of the role in Ansible Galaxy. If this attribute is
746 supplied, Zuul will search Ansible Galaxy for a role by this name
747 and install it. Mutually exclusive with ``zuul``; either
748 ``galaxy`` or ``zuul`` must be supplied.
749
750 **zuul**
751 The name of a Zuul project which supplies the role. Mutually
752 exclusive with ``galaxy``; either ``galaxy`` or ``zuul`` must be
753 supplied.
754
755 **name**
756 The installation name of the role. In the case of a bare role,
757 the role will be made available under this name. Ignored in the
758 case of a contained role.
759
760**required-projects**
761 A list of other projects which are used by this job. Any Zuul
762 projects specified here will also be checked out by Zuul into the
763 working directory for the job. Speculative merging and cross-repo
764 dependencies will be honored.
765
766 The format for this attribute is either a list of strings or
767 dictionaries. Strings are interpreted as project names,
768 dictionaries may have the following attributes:
769
770 **name**
771 The name of the required project.
772
773 **override-branch**
774 When Zuul runs jobs for a proposed change, it normally checks out
775 the branch associated with that change on every project present in
776 the job. If jobs are running on a ref (such as a branch tip or
777 tag), then that ref is normally checked out. This attribute is
778 used to override that behavior and indicate that this job should,
779 regardless of the branch for the queue item, use the indicated
780 branch instead, for only this project. See also the
781 **override-branch** attribute of jobs to apply the same behavior
782 to all projects in a job.
783
784**vars**
785
786A dictionary of variables to supply to Ansible. When inheriting from
787a job (or creating a variant of a job) vars are merged with previous
788definitions. This means a variable definition with the same name will
789override a previously defined variable, but new variable names will be
790added to the set of defined variables.
791
792**dependencies**
793 A list of other jobs upon which this job depends. Zuul will not
794 start executing this job until all of its dependencies have
795 completed successfully, and if one or more of them fail, this job
796 will not be run.
797
798**allowed-projects**
799 A list of Zuul projects which may use this job. By default, a job
800 may be used by any other project known to Zuul, however, some jobs
801 use resources or perform actions which are not appropriate for other
802 projects. In these cases, a list of projects which are allowed to
803 use this job may be supplied. If this list is not empty, then it
804 must be an exhaustive list of all projects permitted to use the job.
805 The current project (where the job is defined) is not automatically
806 included, so if it should be able to run this job, then it must be
807 explicitly listed. Default: the empty list (all projects may use
808 the job).
809
810
811.. _project:
812
813Project
814~~~~~~~
815
816A project corresponds to a source code repository with which Zuul is
817configured to interact. The main responsibility of the `Project`
818configuration item is to specify which jobs should run in which
819pipelines for a given project. Within each `Project` definition, a
820section for each `Pipeline` may appear. This project-pipeline
821definition is what determines how a project participates in a
822pipeline.
823
824Consider the following `Project` definition::
825
826 - project:
827 name: yoyodyne
828 check:
829 jobs:
830 - check-syntax
831 - unit-tests
832 gate:
833 queue: integrated
834 jobs:
835 - unit-tests
836 - integration-tests
837
838The project has two project-pipeline stanzas, one for the `check`
839pipeline, and one for `gate`. Each specifies which jobs shuld run
840when a change for that project enteres the respective pipeline -- when
841a change enters `check`, the `check-syntax` and `unit-test` jobs are
842run.
843
844Pipelines which use the dependent pipeline manager (e.g., the `gate`
845example shown earlier) maintain separate queues for groups of
846projects. When Zuul serializes a set of changes which represent
847future potential project states, it must know about all of the
848projects within Zuul which may have an effect on the outcome of the
849jobs it runs. If project *A* uses project *B* as a library, then Zuul
850must be told about that relationship so that it knows to serialize
851changes to A and B together, so that it does not merge a change to B
852while it is testing a change to A.
853
854Zuul could simply assume that all projects are related, or even infer
855relationships by which projects a job indicates it uses, however, in a
856large system that would become unwieldy very quickly, and
857unnecessarily delay changes to unrelated projects. To allow for
858flexibility in the construction of groups of related projects, the
859change queues used by dependent pipeline managers are specified
860manually. To group two or more related projects into a shared queue
861for a dependent pipeline, set the ``queue`` parameter to the same
862value for those projects.
863
864The `gate` project-pipeline definition above specifies that this
865project participates in the `integrated` shared queue for that
866pipeline.
867
868In addition to a project-pipeline definition for one or more
869`Pipelines`, the following attributes may appear in a Project:
870
871**name** (required)
872 The name of the project. If Zuul is configured with two or more
873 unique projects with the same name, the canonical hostname for the
874 project should be included (e.g., `git.example.com/foo`).
875
876**templates**
877 A list of :ref:`project-template` references; the project-pipeline
878 definitions of each Project Template will be applied to this
879 project. If more than one template includes jobs for a given
880 pipeline, they will be combined, as will any jobs specified in
881 project-pipeline definitions on the project itself.
882
883.. _project-template:
884
885Project Template
886~~~~~~~~~~~~~~~~
887
888A Project Template defines one or more project-pipeline definitions
889which can be re-used by multiple projects.
890
891A Project Template uses the same syntax as a :ref:`project`
892definition, however, in the case of a template, the ``name`` attribute
893does not refer to the name of a project, but rather names the template
894so that it can be referenced in a `Project` definition.
895
896.. _secret:
897
898Secret
899~~~~~~
900
901A Secret is a collection of private data for use by one or more jobs.
902In order to maintain the security of the data, the values are usually
903encrypted, however, data which are not sensitive may be provided
904unencrypted as well for convenience.
905
906A Secret may only be used by jobs defined within the same project. To
907use a secret, a :ref:`job` must specify the secret within its `auth`
908section. To protect against jobs in other repositories declaring a
909job with a secret as a parent and then exposing that secret, jobs
910which inherit from a job with secrets will not inherit the secrets
911themselves. To alter that behavior, see the `inherit` job attribute.
912Further, jobs which do not permit children to inherit secrets (the
913default) are also automatically marked `final`, meaning that their
914execution related attributes may not be changed in a project-pipeline
915stanza. This is to protect against a job with secrets defined in one
916project being used by another project in a way which might expose the
917secrets. If a job with secrets is unsafe to be used by other
918projects, the `allowed-projects` job attribute can be used to restrict
919the projects which can invoke that job. Finally, pipelines which are
920used to execute proposed but unreviewed changes can set the
921`allow-secrets` attribute to indicate that they should not supply
922secrets at all in order to protect against someone proposing a change
923which exposes a secret.
924
925The following attributes are required:
926
927**name** (required)
928 The name of the secret, used in a :ref:`Job` definition to request
929 the secret.
930
931**data** (required)
932 A dictionary which will be added to the Ansible variables available
933 to the job. The values can either be plain text strings, or
934 encrypted values. See :ref:`encryption` for more information.
935
936.. _nodeset:
937
938Nodeset
939~~~~~~~
940
941A Nodeset is a named collection of nodes for use by a job. Jobs may
942specify what nodes they require individually, however, by defining
943groups of node types once and referring to them by name, job
944configuration may be simplified.
945
946A Nodeset requires two attributes:
947
948**name** (required)
949 The name of the Nodeset, to be referenced by a :ref:`job`.
950
951**nodes** (required)
952 A list of node definitions, each of which has the following format:
953
954 **name** (required)
955 The name of the node. This will appear in the Ansible inventory
956 for the job.
957
958 **label** (required)
959 The Nodepool label for the node. Zuul will request a node with
960 this label.
961
962.. _semaphore:
963
964Semaphore
965~~~~~~~~~
966
967Semaphores can be used to restrict the number of certain jobs which
968are running at the same time. This may be useful for jobs which
969access shared or limited resources. A semaphore has a value which
970represents the maximum number of jobs which use that semaphore at the
971same time.
972
973Semaphores are never subject to dynamic reconfiguration. If the value
974of a semaphore is changed, it will take effect only when the change
975where it is updated is merged. An example follows::
976
977 - semaphore:
978 name: semaphore-foo
979 max: 5
980 - semaphore:
981 name: semaphore-bar
982 max: 3
983
984The following attributes are available:
985
986**name** (required)
987 The name of the semaphore, referenced by jobs.
988
989**max**
990 The maximum number of running jobs which can use this semaphore.
991 Defaults to 1.