blob: 0e9d6cf5b83bacc47323c9bfd23cff643199d70e [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
James E. Blair1761e862017-07-25 16:15:47 -070078.. zuul:configobject:: Pipeline
79
James E. Blair1de8d402017-05-07 17:08:04 -070080Pipeline
81~~~~~~~~
82
83A pipeline describes a workflow operation in Zuul. It associates jobs
84for a given project with triggering and reporting events.
85
86Its flexible configuration allows for characterizing any number of
87workflows, and by specifying each as a named configuration, makes it
88easy to apply similar workflow operations to projects or groups of
89projects.
90
91By way of example, one of the primary uses of Zuul is to perform
92project gating. To do so, one can create a *gate* pipeline which
93tells Zuul that when a certain event (such as approval by a code
94reviewer) occurs, the corresponding change or pull request should be
95enqueued into the pipeline. When that happens, the jobs which have
96been configured to run for that project in the *gate* pipeline are
97run, and when they complete, the pipeline reports the results to the
98user.
99
100Pipeline configuration items may only appear in *config-projects*.
101
102Generally, a Zuul administrator would define a small number of
103pipelines which represent the workflow processes used in their
104environment. Each project can then be added to the available
105pipelines as appropriate.
106
107Here is an example *check* pipeline, which runs whenever a new
108patchset is created in Gerrit. If the associated jobs all report
109success, the pipeline reports back to Gerrit with a *Verified* vote of
110+1, or if at least one of them fails, a -1::
111
112 - pipeline:
James E. Blaira8387ec2017-07-05 14:00:12 -0700113 name: check
James E. Blair1de8d402017-05-07 17:08:04 -0700114 manager: independent
115 trigger:
116 my_gerrit:
117 - event: patchset-created
118 success:
119 my_gerrit:
Tobias Henkelea98a192017-05-29 21:15:17 +0200120 Verified: 1
James E. Blair1de8d402017-05-07 17:08:04 -0700121 failure:
122 my_gerrit
Tobias Henkelea98a192017-05-29 21:15:17 +0200123 Verified: -1
James E. Blair1de8d402017-05-07 17:08:04 -0700124
James E. Blaireff5a9d2017-06-20 00:00:37 -0700125.. TODO: See TODO for more annotated examples of common pipeline configurations.
James E. Blair1de8d402017-05-07 17:08:04 -0700126
127The attributes available on a pipeline are as follows (all are
128optional unless otherwise specified):
129
James E. Blair1761e862017-07-25 16:15:47 -0700130.. zuul:attr:: name
131 :required:
James E. Blair1de8d402017-05-07 17:08:04 -0700132
James E. Blair1761e862017-07-25 16:15:47 -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. Blair1761e862017-07-25 16:15:47 -0700136.. zuul:attr:: manager
137 :required:
James E. Blaireff5a9d2017-06-20 00:00:37 -0700138
James E. Blair1761e862017-07-25 16:15:47 -0700139 There are currently two schemes for managing pipelines:
James E. Blair1de8d402017-05-07 17:08:04 -0700140
James E. Blair1761e862017-07-25 16:15:47 -0700141 .. _independent_pipeline_manager:
James E. Blair1de8d402017-05-07 17:08:04 -0700142
James E. Blair1761e862017-07-25 16:15:47 -0700143 .. zuul:attr:: independent
James E. Blaireff5a9d2017-06-20 00:00:37 -0700144
James E. Blair1761e862017-07-25 16:15:47 -0700145 Every event in this pipeline should be treated as independent of
146 other events in the pipeline. This is appropriate when the order
147 of events in the pipeline doesn't matter because the results of
148 the actions this pipeline performs can not affect other events in
149 the pipeline. For example, when a change is first uploaded for
150 review, you may want to run tests on that change to provide early
151 feedback to reviewers. At the end of the tests, the change is
152 not going to be merged, so it is safe to run these tests in
153 parallel without regard to any other changes in the pipeline.
154 They are independent.
James E. Blair1de8d402017-05-07 17:08:04 -0700155
James E. Blair1761e862017-07-25 16:15:47 -0700156 Another type of pipeline that is independent is a post-merge
157 pipeline. In that case, the changes have already merged, so the
158 results can not affect any other events in the pipeline.
159
160 .. _dependent_pipeline_manager:
161
162 .. zuul:attr:: dependent
163
164 The dependent pipeline manager is designed for gating. It
165 ensures that every change is tested exactly as it is going to be
166 merged into the repository. An ideal gating system would test
167 one change at a time, applied to the tip of the repository, and
168 only if that change passed tests would it be merged. Then the
169 next change in line would be tested the same way. In order to
170 achieve parallel testing of changes, the dependent pipeline
171 manager performs speculative execution on changes. It orders
172 changes based on their entry into the pipeline. It begins
173 testing all changes in parallel, assuming that each change ahead
174 in the pipeline will pass its tests. If they all succeed, all
175 the changes can be tested and merged in parallel. If a change
176 near the front of the pipeline fails its tests, each change
177 behind it ignores whatever tests have been completed and are
178 tested again without the change in front. This way gate tests
179 may run in parallel but still be tested correctly, exactly as
180 they will appear in the repository when merged.
181
182 For more detail on the theory and operation of Zuul's dependent
183 pipeline manager, see: :doc:`gating`.
James E. Blair1de8d402017-05-07 17:08:04 -0700184
James E. Blairf17aa9c2017-07-05 13:21:23 -0700185**allow-secrets**
186 This is a boolean which can be used to prevent jobs which require
187 secrets from running in this pipeline. Some pipelines run on
188 proposed changes and therefore execute code which has not yet been
189 reviewed. In such a case, allowing a job to use a secret could
190 result in that secret being exposed. The default is False, meaning
191 that in order to run jobs with secrets, this must be explicitly
192 enabled on each Pipeline where that is safe.
193
194 For more information, see :ref:`secret`.
195
James E. Blair1de8d402017-05-07 17:08:04 -0700196**description**
197 This field may be used to provide a textual description of the
198 pipeline. It may appear in the status page or in documentation.
199
200**success-message**
201 The introductory text in reports when all the voting jobs are
202 successful. Defaults to "Build successful."
203
204**failure-message**
205 The introductory text in reports when at least one voting job fails.
206 Defaults to "Build failed."
207
208**merge-failure-message**
209 The introductory text in the message reported when a change fails to
210 merge with the current state of the repository. Defaults to "Merge
211 failed."
212
213**footer-message**
214 Supplies additional information after test results. Useful for
215 adding information about the CI system such as debugging and contact
216 details.
217
218**trigger**
219 At least one trigger source must be supplied for each pipeline.
220 Triggers are not exclusive -- matching events may be placed in
221 multiple pipelines, and they will behave independently in each of
222 the pipelines they match.
223
224 Triggers are loaded from their connection name. The driver type of
225 the connection will dictate which options are available.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700226 See :ref:`drivers`.
James E. Blair1de8d402017-05-07 17:08:04 -0700227
228**require**
229 If this section is present, it established pre-requisites for any
230 kind of item entering the Pipeline. Regardless of how the item is
231 to be enqueued (via any trigger or automatic dependency resolution),
232 the conditions specified here must be met or the item will not be
233 enqueued.
234
James E. Blaireff5a9d2017-06-20 00:00:37 -0700235.. _pipeline-require-approval:
James E. Blair1de8d402017-05-07 17:08:04 -0700236
237 **approval**
238 This requires that a certain kind of approval be present for the
239 current patchset of the change (the approval could be added by the
240 event in question). It takes several sub-parameters, all of which
241 are optional and are combined together so that there must be an
242 approval matching all specified requirements.
243
244 *username*
245 If present, an approval from this username is required. It is
246 treated as a regular expression.
247
248 *email*
249 If present, an approval with this email address is required. It
250 is treated as a regular expression.
251
252 *email-filter* (deprecated)
253 A deprecated alternate spelling of *email*. Only one of *email* or
254 *email_filter* should be used.
255
256 *older-than*
257 If present, the approval must be older than this amount of time
258 to match. Provide a time interval as a number with a suffix of
259 "w" (weeks), "d" (days), "h" (hours), "m" (minutes), "s"
260 (seconds). Example ``48h`` or ``2d``.
261
262 *newer-than*
263 If present, the approval must be newer than this amount of time
264 to match. Same format as "older-than".
265
266 Any other field is interpreted as a review category and value
Tobias Henkelea98a192017-05-29 21:15:17 +0200267 pair. For example ``Verified: 1`` would require that the approval
James E. Blair1de8d402017-05-07 17:08:04 -0700268 be for a +1 vote in the "Verified" column. The value may either
Tobias Henkelea98a192017-05-29 21:15:17 +0200269 be a single value or a list: ``Verified: [1, 2]`` would match
James E. Blair1de8d402017-05-07 17:08:04 -0700270 either a +1 or +2 vote.
271
272 **open**
273 A boolean value (``true`` or ``false``) that indicates whether the change
274 must be open or closed in order to be enqueued.
275
276 **current-patchset**
277 A boolean value (``true`` or ``false``) that indicates whether the change
278 must be the current patchset in order to be enqueued.
279
280 **status**
281 A string value that corresponds with the status of the change
282 reported by the trigger.
283
284**reject**
285 If this section is present, it establishes pre-requisites that can
286 block an item from being enqueued. It can be considered a negative
287 version of **require**.
288
289 **approval**
290 This takes a list of approvals. If an approval matches the provided
291 criteria the change can not be entered into the pipeline. It follows
292 the same syntax as the :ref:`"require approval" pipeline above
293 <pipeline-require-approval>`.
294
295 Example to reject a change with any negative vote::
296
297 reject:
298 approval:
Tobias Henkelea98a192017-05-29 21:15:17 +0200299 - Code-Review: [-1, -2]
James E. Blair1de8d402017-05-07 17:08:04 -0700300
301**dequeue-on-new-patchset**
302 Normally, if a new patchset is uploaded to a change that is in a
303 pipeline, the existing entry in the pipeline will be removed (with
304 jobs canceled and any dependent changes that can no longer merge as
305 well. To suppress this behavior (and allow jobs to continue
306 running), set this to ``false``. Default: ``true``.
307
308**ignore-dependencies**
309 In any kind of pipeline (dependent or independent), Zuul will
310 attempt to enqueue all dependencies ahead of the current change so
311 that they are tested together (independent pipelines report the
312 results of each change regardless of the results of changes ahead).
313 To ignore dependencies completely in an independent pipeline, set
314 this to ``true``. This option is ignored by dependent pipelines.
315 The default is: ``false``.
316
James E. Blaireff5a9d2017-06-20 00:00:37 -0700317**precedence**
318 Indicates how the build scheduler should prioritize jobs for
319 different pipelines. Each pipeline may have one precedence, jobs
320 for pipelines with a higher precedence will be run before ones with
321 lower. The value should be one of ``high``, ``normal``, or ``low``.
322 Default: ``normal``.
323
James E. Blair1de8d402017-05-07 17:08:04 -0700324The following options configure *reporters*. Reporters are
325complementary to triggers; where a trigger is an event on a connection
326which causes Zuul to enqueue an item, a reporter is the action
327performed on a connection when an item is dequeued after its jobs
328complete. The actual syntax for a reporter is defined by the driver
329which implements it. See :ref:`drivers` for more information.
330
331**success**
332 Describes where Zuul should report to if all the jobs complete
333 successfully. This section is optional; if it is omitted, Zuul will
334 run jobs and do nothing on success -- it will not report at all. If
335 the section is present, the listed reporters will be asked to report
336 on the jobs. The reporters are listed by their connection name. The
337 options available depend on the driver for the supplied connection.
338
339**failure**
340 These reporters describe what Zuul should do if at least one job
341 fails.
342
343**merge-failure**
344 These reporters describe what Zuul should do if it is unable to
345 merge in the patchset. If no merge-failure reporters are listed then
346 the ``failure`` reporters will be used to notify of unsuccessful
347 merges.
348
349**start**
350 These reporters describe what Zuul should do when a change is added
351 to the pipeline. This can be used, for example, to reset a
352 previously reported result.
353
354**disabled**
355 These reporters describe what Zuul should do when a pipeline is
356 disabled. See ``disable-after-consecutive-failures``.
357
James E. Blaireff5a9d2017-06-20 00:00:37 -0700358The following options can be used to alter Zuul's behavior to mitigate
359situations in which jobs are failing frequently (perhaps due to a
360problem with an external dependency, or unusually high
361non-deterministic test failures).
362
James E. Blair1de8d402017-05-07 17:08:04 -0700363**disable-after-consecutive-failures**
364 If set, a pipeline can enter a ''disabled'' state if too many changes
365 in a row fail. When this value is exceeded the pipeline will stop
366 reporting to any of the ``success``, ``failure`` or ``merge-failure``
367 reporters and instead only report to the ``disabled`` reporters.
368 (No ``start`` reports are made when a pipeline is disabled).
369
James E. Blair1de8d402017-05-07 17:08:04 -0700370**window**
371 Dependent pipeline managers only. Zuul can rate limit dependent
372 pipelines in a manner similar to TCP flow control. Jobs are only
373 started for items in the queue if they are within the actionable
374 window for the pipeline. The initial length of this window is
375 configurable with this value. The value given should be a positive
376 integer value. A value of ``0`` disables rate limiting on the
377 DependentPipelineManager. Default: ``20``.
378
379**window-floor**
380 Dependent pipeline managers only. This is the minimum value for the
381 window described above. Should be a positive non zero integer value.
382 Default: ``3``.
383
384**window-increase-type**
385 Dependent pipeline managers only. This value describes how the window
386 should grow when changes are successfully merged by zuul. A value of
387 ``linear`` indicates that ``window-increase-factor`` should be added
388 to the previous window value. A value of ``exponential`` indicates
389 that ``window-increase-factor`` should be multiplied against the
390 previous window value and the result will become the window size.
391 Default: ``linear``.
392
393**window-increase-factor**
394 Dependent pipeline managers only. The value to be added or multiplied
395 against the previous window value to determine the new window after
396 successful change merges.
397 Default: ``1``.
398
399**window-decrease-type**
400 Dependent pipeline managers only. This value describes how the window
401 should shrink when changes are not able to be merged by Zuul. A value
402 of ``linear`` indicates that ``window-decrease-factor`` should be
403 subtracted from the previous window value. A value of ``exponential``
404 indicates that ``window-decrease-factor`` should be divided against
405 the previous window value and the result will become the window size.
406 Default: ``exponential``.
407
408**window-decrease-factor**
409 Dependent pipline managers only. The value to be subtracted or divided
410 against the previous window value to determine the new window after
411 unsuccessful change merges.
412 Default: ``2``.
413
414
415.. _job:
416
417Job
418~~~
419
420A job is a unit of work performed by Zuul on an item enqueued into a
421pipeline. Items may run any number of jobs (which may depend on each
422other). Each job is an invocation of an Ansible playbook with a
423specific inventory of hosts. The actual tasks that are run by the job
424appear in the playbook for that job while the attributes that appear in the
425Zuul configuration specify information about when, where, and how the
426job should be run.
427
428Jobs in Zuul support inheritance. Any job may specify a single parent
429job, and any attributes not set on the child job are collected from
430the parent job. In this way, a configuration structure may be built
431starting with very basic jobs which describe characteristics that all
432jobs on the system should have, progressing through stages of
433specialization before arriving at a particular job. A job may inherit
434from any other job in any project (however, if the other job is marked
435as `final`, some attributes may not be overidden).
436
437Jobs also support a concept called variance. The first time a job
438definition appears is called the reference definition of the job.
439Subsequent job definitions with the same name are called variants.
440These may have different selection criteria which indicate to Zuul
441that, for instance, the job should behave differently on a different
442git branch. Unlike inheritance, all job variants must be defined in
443the same project.
444
445When Zuul decides to run a job, it performs a process known as
446freezing the job. Because any number of job variants may be
447applicable, Zuul collects all of the matching variants and applies
448them in the order they appeared in the configuration. The resulting
449frozen job is built from attributes gathered from all of the
450matching variants. In this way, exactly what is run is dependent on
451the pipeline, project, branch, and content of the item.
452
453In addition to the job's main playbook, each job may specify one or
454more pre- and post-playbooks. These are run, in order, before and
455after (respectively) the main playbook. They may be used to set up
456and tear down resources needed by the main playbook. When combined
457with inheritance, they provide powerful tools for job construction. A
458job only has a single main playbook, and when inheriting from a
459parent, the child's main playbook overrides (or replaces) the
460parent's. However, the pre- and post-playbooks are appended and
461prepended in a nesting fashion. So if a parent job and child job both
462specified pre and post playbooks, the sequence of playbooks run would
463be:
464
465* parent pre-run playbook
466* child pre-run playbook
467* child playbook
468* child post-run playbook
469* parent post-run playbook
470
471Further inheritance would nest even deeper.
472
473Here is an example of two job definitions::
474
475 - job:
476 name: base
477 pre-run: copy-git-repos
478 post-run: copy-logs
479
480 - job:
481 name: run-tests
482 parent: base
483 nodes:
484 - name: test-node
485 image: fedora
486
487The following attributes are available on a job; all are optional
488unless otherwise specified:
489
490**name** (required)
491 The name of the job. By default, Zuul looks for a playbook with
492 this name to use as the main playbook for the job. This name is
493 also referenced later in a project pipeline configuration.
494
495**parent**
496 Specifies a job to inherit from. The parent job can be defined in
497 this or any other project. Any attributes not specified on a job
498 will be collected from its parent.
499
500**description**
501 A textual description of the job. Not currently used directly by
502 Zuul, but it is used by the zuul-sphinx extension to Sphinx to
503 auto-document Zuul jobs (in which case it is interpreted as
504 ReStructuredText.
505
506**success-message**
507 Normally when a job succeeds, the string "SUCCESS" is reported as
508 the result for the job. If set, this option may be used to supply a
509 different string. Default: "SUCCESS".
510
511**failure-message**
512 Normally when a job fails, the string "FAILURE" is reported as
513 the result for the job. If set, this option may be used to supply a
514 different string. Default: "FAILURE".
515
516**success-url**
James E. Blair88e79c02017-07-07 13:36:54 -0700517 When a job succeeds, this URL is reported along with the result. If
518 this value is not supplied, Zuul uses the content of the job
519 :ref:`return value <return_values>` **zuul.log_url**. This is
520 recommended as it allows the code which stores the URL to the job
521 artifacts to report exactly where they were stored. To override
522 this value, or if it is not set, supply an absolute URL in this
523 field. If a relative URL is supplied in this field, and
524 **zuul.log_url** is set, then the two will be combined to produce
525 the URL used for the report. This can be used to specify that
526 certain jobs should "deep link" into the stored job artifacts.
James E. Blair1de8d402017-05-07 17:08:04 -0700527 Default: none.
528
529**failure-url**
530 When a job fails, this URL is reported along with the result.
James E. Blair88e79c02017-07-07 13:36:54 -0700531 Otherwise behaves the same as **success-url**.
James E. Blair1de8d402017-05-07 17:08:04 -0700532
533**hold-following-changes**
534 In a dependent pipeline, this option may be used to indicate that no
535 jobs should start on any items which depend on the current item
536 until this job has completed successfully. This may be used to
537 conserve build resources, at the expense of inhibiting the
538 parallelization which speeds the processing of items in a dependent
539 pipeline. A boolean value, default: false.
540
541**voting**
542 Indicates whether the result of this job should be used in
543 determining the overall result of the item. A boolean value,
544 default: true.
545
546**semaphore**
547 The name of a :ref:`semaphore` which should be acquired and released
548 when the job begins and ends. If the semaphore is at maximum
549 capacity, then Zuul will wait until it can be acquired before
550 starting the job. Default: none.
551
552**tags**
553 Metadata about this job. Tags are units of information attached to
554 the job; they do not affect Zuul's behavior, but they can be used
555 within the job to characterize the job. For example, a job which
556 tests a certain subsystem could be tagged with the name of that
557 subsystem, and if the job's results are reported into a database,
558 then the results of all jobs affecting that subsystem could be
559 queried. This attribute is specified as a list of strings, and when
560 inheriting jobs or applying variants, tags accumulate in a set, so
561 the result is always a set of all the tags from all the jobs and
562 variants used in constructing the frozen job, with no duplication.
563 Default: none.
564
James E. Blaireff5a9d2017-06-20 00:00:37 -0700565**branches**
James E. Blair1de8d402017-05-07 17:08:04 -0700566 A regular expression (or list of regular expressions) which describe
567 on what branches a job should run (or in the case of variants: to
568 alter the behavior of a job for a certain branch).
569
570 If there is no job definition for a given job which matches the
571 branch of an item, then that job is not run for the item.
572 Otherwise, all of the job variants which match that branch (and any
573 other selection criteria) are used when freezing the job.
574
575 This example illustrates a job called *run-tests* which uses a
576 nodeset based on the current release of an operating system to
577 perform its tests, except when testing changes to the stable/2.0
578 branch, in which case it uses an older release::
579
580 - job:
581 name: run-tests
582 nodes: current-release
583
584 - job:
585 name: run-tests
586 branch: stable/2.0
587 nodes: old-release
588
589 In some cases, Zuul uses an implied value for the branch specifier
590 if none is supplied:
591
592 * For a job definition in a *config-project*, no implied branch
593 specifier is used. If no branch specifier appears, the job
594 applies to all branches.
595
596 * In the case of an *untrusted-project*, no implied branch specifier
597 is applied to the reference definition of a job. That is to say,
598 that if the first appearance of the job definition appears without
599 a branch specifier, then it will apply to all branches. Note that
600 when collecting its configuration, Zuul reads the `master` branch
601 of a given project first, then other branches in alphabetical
602 order.
603
604 * Any further job variants other than the reference definition in an
605 *untrusted-project* will, if they do not have a branch specifier,
606 will have an implied branch specifier for the current branch
607 applied.
608
609 This allows for the very simple and expected workflow where if a
610 project defines a job on the master branch with no branch specifier,
611 and then creates a new branch based on master, any changes to that
612 job definition within the new branch only affect that branch.
613
614**files**
615 This attribute indicates that the job should only run on changes
616 where the specified files are modified. This is a regular
617 expression or list of regular expressions. Default: none.
618
619**irrelevant-files**
620 This is a negative complement of `files`. It indicates that the job
621 should run unless *all* of the files changed match this list. In
622 other words, if the regular expression `docs/.*` is supplied, then
623 this job will not run if the only files changed are in the docs
624 directory. A regular expression or list of regular expressions.
625 Default: none.
626
627**auth**
628 Authentication information to be made available to the job. This is
629 a dictionary with two potential keys:
630
631 **inherit**
632 A boolean indicating that the authentication information referenced
633 by this job should be able to be inherited by child jobs. Normally
634 when a job inherits from another job, the auth section is not
635 included. This permits jobs to inherit the same basic structure and
636 playbook, but ensures that secret information is unable to be
637 exposed by a child job which may alter the job's behavior. If it is
638 safe for the contents of the authentication section to be used by
639 child jobs, set this to ``true``. Default: ``false``.
640
641 **secrets**
642 A list of secrets which may be used by the job. A :ref:`secret` is
643 a named collection of private information defined separately in the
644 configuration. The secrets that appear here must be defined in the
645 same project as this job definition.
646
647 In the future, other types of authentication information may be
648 added.
649
650**nodes**
651 A list of nodes which should be supplied to the job. This parameter
652 may be supplied either as a string, in which case it references a
653 :ref:`nodeset` definition which appears elsewhere in the
654 configuration, or a list, in which case it is interpreted in the
655 same way as a Nodeset definition (in essence, it is an anonymous
656 Node definition unique to this job). See the :ref:`nodeset`
657 reference for the syntax to use in that case.
658
659 If a job has an empty or no node definition, it will still run and
660 may be able to perform actions on the Zuul executor.
661
662**override-branch**
663 When Zuul runs jobs for a proposed change, it normally checks out
664 the branch associated with that change on every project present in
665 the job. If jobs are running on a ref (such as a branch tip or
666 tag), then that ref is normally checked out. This attribute is used
667 to override that behavior and indicate that this job should,
668 regardless of the branch for the queue item, use the indicated
669 branch instead. This can be used, for example, to run a previous
670 version of the software (from a stable maintenance branch) under
671 test even if the change being tested applies to a different branch
672 (this is only likely to be useful if there is some cross-branch
673 interaction with some component of the system being tested). See
674 also the project-specific **override-branch** attribute under
675 **required-projects** to apply this behavior to a subset of a job's
676 projects.
677
678**timeout**
679 The time in minutes that the job should be allowed to run before it
680 is automatically aborted and failure is reported. If no timeout is
681 supplied, the job may run indefinitely. Supplying a timeout is
682 highly recommended.
683
684**attempts**
685 When Zuul encounters an error running a job's pre-run playbook, Zuul
686 will stop and restart the job. Errors during the main or
687 post-run -playbook phase of a job are not affected by this parameter
688 (they are reported immediately). This parameter controls the number
689 of attempts to make before an error is reported. Default: 3.
690
691**pre-run**
Tobias Henkel2aade262017-07-12 16:09:06 +0200692 The name of a playbook or list of playbooks without file extension
693 to run before the main body of a job. The full path to the playbook
694 in the repo where the job is defined is expected.
James E. Blair1de8d402017-05-07 17:08:04 -0700695
696 When a job inherits from a parent, the child's pre-run playbooks are
697 run after the parent's. See :ref:`job` for more information.
698
699**post-run**
Tobias Henkel2aade262017-07-12 16:09:06 +0200700 The name of a playbook or list of playbooks without file extension
701 to run after the main body of a job. The full path to the playbook
702 in the repo where the job is defined is expected.
James E. Blair1de8d402017-05-07 17:08:04 -0700703
704 When a job inherits from a parent, the child's post-run playbooks
705 are run before the parent's. See :ref:`job` for more information.
706
707**run**
Tobias Henkel2aade262017-07-12 16:09:06 +0200708 The name of the main playbook for this job. This parameter is
709 not normally necessary, as it defaults to a playbook with the
710 same name as the job inside of the `playbooks/` directory (e.g.,
711 the `foo` job would default to `playbooks/foo`. However, if a
712 playbook with a different name is needed, it can be specified
713 here. The file extension is not required, but the full path
714 within the repo is. When a child inherits from a parent, a
715 playbook with the name of the child job is implicitly searched
716 first, before falling back on the playbook used by the parent
717 job (unless the child job specifies a ``run`` attribute, in which
718 case that value is used). Example::
719
720 run: playbooks/<name of the job>
James E. Blair1de8d402017-05-07 17:08:04 -0700721
722**roles**
723 A list of Ansible roles to prepare for the job. Because a job runs
724 an Ansible playbook, any roles which are used by the job must be
725 prepared and installed by Zuul before the job begins. This value is
726 a list of dictionaries, each of which indicates one of two types of
727 roles: a Galaxy role, which is simply a role that is installed from
728 Ansible Galaxy, or a Zuul role, which is a role provided by a
729 project managed by Zuul. Zuul roles are able to benefit from
James E. Blair74a82cf2017-07-12 17:23:08 -0700730 speculative merging and cross-project dependencies when used by
James E. Blair4eec8282017-07-12 17:33:26 -0700731 playbooks in untrusted projects. Roles are added to the Ansible
732 role path in the order they appear on the job -- roles earlier in
733 the list will take precedence over those which follow.
James E. Blair74a82cf2017-07-12 17:23:08 -0700734
735 In the case of job inheritance or variance, the roles used for each
736 of the playbooks run by the job will be only those which were
737 defined along with that playbook. If a child job inherits from a
738 parent which defines a pre and post playbook, then the pre and post
739 playbooks it inherits from the parent job will run only with the
740 roles that were defined on the parent. If the child adds its own
741 pre and post playbooks, then any roles added by the child will be
742 available to the child's playbooks. This is so that a job which
743 inherits from a parent does not inadvertantly alter the behavior of
James E. Blair4eec8282017-07-12 17:33:26 -0700744 the parent's playbooks by the addition of conflicting roles. Roles
745 added by a child will appear before those it inherits from its
746 parent.
James E. Blair1de8d402017-05-07 17:08:04 -0700747
748 A project which supplies a role may be structured in one of two
749 configurations: a bare role (in which the role exists at the root of
750 the project), or a contained role (in which the role exists within
751 the `roles/` directory of the project, perhaps along with other
752 roles). In the case of a contained role, the `roles/` directory of
753 the project is added to the role search path. In the case of a bare
754 role, the project itself is added to the role search path. In case
755 the name of the project is not the name under which the role should
756 be installed (and therefore referenced from Ansible), the `name`
757 attribute may be used to specify an alternate.
758
James E. Blairbb94dfa2017-07-11 07:45:19 -0700759 A job automatically has the project in which it is defined added to
760 the roles path if that project appears to contain a role or `roles/`
761 directory. By default, the project is added to the path under its
762 own name, however, that may be changed by explicitly listing the
763 project in the roles list in the usual way.
764
James E. Blaireff5a9d2017-06-20 00:00:37 -0700765 .. note:: galaxy roles are not yet implemented
766
James E. Blair1de8d402017-05-07 17:08:04 -0700767 **galaxy**
768 The name of the role in Ansible Galaxy. If this attribute is
769 supplied, Zuul will search Ansible Galaxy for a role by this name
770 and install it. Mutually exclusive with ``zuul``; either
771 ``galaxy`` or ``zuul`` must be supplied.
772
773 **zuul**
774 The name of a Zuul project which supplies the role. Mutually
775 exclusive with ``galaxy``; either ``galaxy`` or ``zuul`` must be
776 supplied.
777
778 **name**
779 The installation name of the role. In the case of a bare role,
780 the role will be made available under this name. Ignored in the
781 case of a contained role.
782
783**required-projects**
784 A list of other projects which are used by this job. Any Zuul
785 projects specified here will also be checked out by Zuul into the
786 working directory for the job. Speculative merging and cross-repo
787 dependencies will be honored.
788
789 The format for this attribute is either a list of strings or
790 dictionaries. Strings are interpreted as project names,
791 dictionaries may have the following attributes:
792
793 **name**
794 The name of the required project.
795
796 **override-branch**
797 When Zuul runs jobs for a proposed change, it normally checks out
798 the branch associated with that change on every project present in
799 the job. If jobs are running on a ref (such as a branch tip or
800 tag), then that ref is normally checked out. This attribute is
801 used to override that behavior and indicate that this job should,
802 regardless of the branch for the queue item, use the indicated
803 branch instead, for only this project. See also the
804 **override-branch** attribute of jobs to apply the same behavior
805 to all projects in a job.
806
807**vars**
808
809A dictionary of variables to supply to Ansible. When inheriting from
810a job (or creating a variant of a job) vars are merged with previous
811definitions. This means a variable definition with the same name will
812override a previously defined variable, but new variable names will be
813added to the set of defined variables.
814
815**dependencies**
816 A list of other jobs upon which this job depends. Zuul will not
817 start executing this job until all of its dependencies have
818 completed successfully, and if one or more of them fail, this job
819 will not be run.
820
821**allowed-projects**
822 A list of Zuul projects which may use this job. By default, a job
823 may be used by any other project known to Zuul, however, some jobs
824 use resources or perform actions which are not appropriate for other
825 projects. In these cases, a list of projects which are allowed to
826 use this job may be supplied. If this list is not empty, then it
827 must be an exhaustive list of all projects permitted to use the job.
828 The current project (where the job is defined) is not automatically
829 included, so if it should be able to run this job, then it must be
830 explicitly listed. Default: the empty list (all projects may use
831 the job).
832
833
834.. _project:
835
836Project
837~~~~~~~
838
839A project corresponds to a source code repository with which Zuul is
840configured to interact. The main responsibility of the `Project`
841configuration item is to specify which jobs should run in which
842pipelines for a given project. Within each `Project` definition, a
843section for each `Pipeline` may appear. This project-pipeline
844definition is what determines how a project participates in a
845pipeline.
846
847Consider the following `Project` definition::
848
849 - project:
850 name: yoyodyne
851 check:
852 jobs:
853 - check-syntax
854 - unit-tests
855 gate:
856 queue: integrated
857 jobs:
858 - unit-tests
859 - integration-tests
860
861The project has two project-pipeline stanzas, one for the `check`
862pipeline, and one for `gate`. Each specifies which jobs shuld run
863when a change for that project enteres the respective pipeline -- when
864a change enters `check`, the `check-syntax` and `unit-test` jobs are
865run.
866
867Pipelines which use the dependent pipeline manager (e.g., the `gate`
868example shown earlier) maintain separate queues for groups of
869projects. When Zuul serializes a set of changes which represent
870future potential project states, it must know about all of the
871projects within Zuul which may have an effect on the outcome of the
872jobs it runs. If project *A* uses project *B* as a library, then Zuul
873must be told about that relationship so that it knows to serialize
874changes to A and B together, so that it does not merge a change to B
875while it is testing a change to A.
876
877Zuul could simply assume that all projects are related, or even infer
878relationships by which projects a job indicates it uses, however, in a
879large system that would become unwieldy very quickly, and
880unnecessarily delay changes to unrelated projects. To allow for
881flexibility in the construction of groups of related projects, the
882change queues used by dependent pipeline managers are specified
883manually. To group two or more related projects into a shared queue
884for a dependent pipeline, set the ``queue`` parameter to the same
885value for those projects.
886
887The `gate` project-pipeline definition above specifies that this
888project participates in the `integrated` shared queue for that
889pipeline.
890
891In addition to a project-pipeline definition for one or more
892`Pipelines`, the following attributes may appear in a Project:
893
894**name** (required)
895 The name of the project. If Zuul is configured with two or more
896 unique projects with the same name, the canonical hostname for the
897 project should be included (e.g., `git.example.com/foo`).
898
899**templates**
900 A list of :ref:`project-template` references; the project-pipeline
901 definitions of each Project Template will be applied to this
902 project. If more than one template includes jobs for a given
903 pipeline, they will be combined, as will any jobs specified in
904 project-pipeline definitions on the project itself.
905
906.. _project-template:
907
908Project Template
909~~~~~~~~~~~~~~~~
910
911A Project Template defines one or more project-pipeline definitions
912which can be re-used by multiple projects.
913
914A Project Template uses the same syntax as a :ref:`project`
915definition, however, in the case of a template, the ``name`` attribute
916does not refer to the name of a project, but rather names the template
917so that it can be referenced in a `Project` definition.
918
919.. _secret:
920
921Secret
922~~~~~~
923
924A Secret is a collection of private data for use by one or more jobs.
925In order to maintain the security of the data, the values are usually
926encrypted, however, data which are not sensitive may be provided
927unencrypted as well for convenience.
928
929A Secret may only be used by jobs defined within the same project. To
930use a secret, a :ref:`job` must specify the secret within its `auth`
931section. To protect against jobs in other repositories declaring a
932job with a secret as a parent and then exposing that secret, jobs
933which inherit from a job with secrets will not inherit the secrets
934themselves. To alter that behavior, see the `inherit` job attribute.
935Further, jobs which do not permit children to inherit secrets (the
936default) are also automatically marked `final`, meaning that their
937execution related attributes may not be changed in a project-pipeline
938stanza. This is to protect against a job with secrets defined in one
939project being used by another project in a way which might expose the
940secrets. If a job with secrets is unsafe to be used by other
941projects, the `allowed-projects` job attribute can be used to restrict
942the projects which can invoke that job. Finally, pipelines which are
943used to execute proposed but unreviewed changes can set the
944`allow-secrets` attribute to indicate that they should not supply
945secrets at all in order to protect against someone proposing a change
946which exposes a secret.
947
948The following attributes are required:
949
950**name** (required)
951 The name of the secret, used in a :ref:`Job` definition to request
952 the secret.
953
954**data** (required)
955 A dictionary which will be added to the Ansible variables available
956 to the job. The values can either be plain text strings, or
957 encrypted values. See :ref:`encryption` for more information.
958
959.. _nodeset:
960
961Nodeset
962~~~~~~~
963
964A Nodeset is a named collection of nodes for use by a job. Jobs may
965specify what nodes they require individually, however, by defining
966groups of node types once and referring to them by name, job
967configuration may be simplified.
968
969A Nodeset requires two attributes:
970
971**name** (required)
972 The name of the Nodeset, to be referenced by a :ref:`job`.
973
974**nodes** (required)
975 A list of node definitions, each of which has the following format:
976
977 **name** (required)
978 The name of the node. This will appear in the Ansible inventory
979 for the job.
980
981 **label** (required)
982 The Nodepool label for the node. Zuul will request a node with
983 this label.
984
985.. _semaphore:
986
987Semaphore
988~~~~~~~~~
989
990Semaphores can be used to restrict the number of certain jobs which
991are running at the same time. This may be useful for jobs which
992access shared or limited resources. A semaphore has a value which
993represents the maximum number of jobs which use that semaphore at the
994same time.
995
996Semaphores are never subject to dynamic reconfiguration. If the value
997of a semaphore is changed, it will take effect only when the change
998where it is updated is merged. An example follows::
999
1000 - semaphore:
1001 name: semaphore-foo
1002 max: 5
1003 - semaphore:
1004 name: semaphore-bar
1005 max: 3
1006
1007The following attributes are available:
1008
1009**name** (required)
1010 The name of the semaphore, referenced by jobs.
1011
1012**max**
1013 The maximum number of running jobs which can use this semaphore.
1014 Defaults to 1.