James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 1 | :title: Zuul Concepts |
| 2 | |
| 3 | Zuul Concepts |
| 4 | ============= |
| 5 | |
| 6 | Zuul's configuration is organized around the concept of a *pipeline*. |
| 7 | In Zuul, a pipeline encompasses a workflow process which can be |
| 8 | applied to one or more projects. For instance, a "check" pipeline |
| 9 | might describe the actions which should cause newly proposed changes |
| 10 | to projects to be tested. A "gate" pipeline might implement |
| 11 | :ref:`project_gating` to automate merging changes to projects only if |
| 12 | their tests pass. A "post" pipeline might update published |
| 13 | documentation for a project when changes land. |
| 14 | |
| 15 | The names "check", "gate", and "post" are arbitrary -- these are not |
| 16 | concepts built into Zuul, but rather they are just a few common |
| 17 | examples of workflow processes that can be described to Zuul and |
| 18 | implemented as pipelines. |
| 19 | |
| 20 | Once a pipeline has been defined, any number of projects may be |
| 21 | associated with it, each one specifying what jobs should be run for |
| 22 | that project in a given pipeline. |
| 23 | |
| 24 | Pipelines have associated *triggers* which are descriptions of events |
| 25 | which should cause something to be enqueued into a pipeline. For |
| 26 | example, when a patchset is uploaded to Gerrit, a Gerrit |
| 27 | *patchset-created* event is emitted. A pipeline configured to trigger |
| 28 | on *patchset-created* events would then enqueue the associated change |
| 29 | when Zuul receives that event. If there are jobs associated with that |
| 30 | project and pipeline, they will be run. In addition to Gerrit, other |
| 31 | triggers are available, including GitHub, timer, and zuul. See |
| 32 | :ref:`drivers` for a full list of available triggers. |
| 33 | |
| 34 | Once all of the jobs for an item in a pipeline have been run, the |
| 35 | pipeline's *reporters* are responsible for reporting the results of |
| 36 | all of the jobs. Continuing the example from earlier, if a pipeline |
| 37 | were configured with a Gerrit reporter, it would leave a review |
| 38 | comment on the change and set any approval votes that are configured. |
| 39 | There are several reporting phases available; each of which may be |
| 40 | configured with any number of reporters. See :ref:`drivers` for a |
| 41 | full list of available reporters. |
| 42 | |
| 43 | The items enqueued into a pipeline are each associated with a git ref. |
| 44 | That ref may point to a proposed change, or it may be the tip of a |
| 45 | branch or a tag. The triggering event determines the ref, and whether |
| 46 | it represents a proposed or merged commit. Zuul prepares the ref for |
| 47 | an item before running jobs. In the case of a proposed change, that |
| 48 | means speculatively merging the change into its target branch. This |
| 49 | means that any jobs that operate on the change will run with the git |
| 50 | repo in the state it will be in after the change merges (which may be |
| 51 | substantially different than the git repo state of the change itself |
| 52 | since the repo may have merged other changes since the change was |
| 53 | originally authored). Items in a pipeline may depend on other items, |
| 54 | and if they do, all of their dependent changes will be included in the |
| 55 | git repo state that Zuul prepares. For more detail on this process, |
| 56 | see :ref:`project_gating` and :ref:`dependencies`. |
| 57 | |
| 58 | The configuration for nearly everything described above is held in |
| 59 | files inside of the git repos upon which Zuul operates. Zuul's |
| 60 | configuration is global, but distributed. Jobs which are defined in |
| 61 | one project might be used in another project while pipelines are |
| 62 | available to all projects. When Zuul starts, it reads its |
| 63 | configuration from all of the projects it knows about, and when |
| 64 | changes to its configuration are proposed, those changes may take |
| 65 | effect temporarily as part of the proposed change, or immediately |
| 66 | after the change merges, depending on the type of project in which the |
| 67 | change appears. |
| 68 | |
| 69 | Jobs specify the type and quantity of nodes which they require. |
| 70 | Before executing each job, Zuul will contact it's companion program, |
| 71 | Nodepool, to supply them. Nodepool may be configured to supply static |
| 72 | nodes or contact cloud providers to create or delete nodes as |
| 73 | necessary. The types of nodes available to Zuul are determined by the |
| 74 | Nodepool administrator. |
| 75 | |
| 76 | The executable contents of jobs themselves are Ansible playbooks. |
| 77 | Ansible's support for orchestrating tasks on remote nodes is |
| 78 | particularly suited to Zuul's support for multi-node testing. Ansible |
| 79 | is also easy to use for simple tasks (such as executing a shell |
| 80 | script) or sophisticated deployment scenarios. When Zuul runs |
| 81 | Ansible, it attempts to do so in a manner most similar to the way that |
| 82 | Ansible might be used to orchestrate remote systems. Ansible itself |
| 83 | is run on the executor and acts remotely upon the test nodes supplied |
| 84 | to a job. This facilitates continuous delivery by making it possible |
| 85 | to use the same Ansible playbooks in testing and production. |