Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Commit

Permalink
Support multiple triggers
Browse files Browse the repository at this point in the history
Add the ability for Zuul to accept inputs from multiple trigger
sources simultaneously.

Pipelines are associated with exactly one trigger, which must now
be named in the configuration file.

Co-Authored-By: Monty Taylor <mordred@inaugust.com>

Change-Id: Ief2b31a7b8d85d30817f2747c1e2635f71ea24b9
  • Loading branch information
James E. Blair committed Aug 1, 2013
1 parent 3cd2503 commit 6c358e7
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 153 deletions.
8 changes: 7 additions & 1 deletion NEWS.rst
Expand Up @@ -11,13 +11,19 @@ Since 1.3.0:
QueueItem has the full context for why the change is being run
(including the pipeline, items ahead and behind, etc.). The Change
is still available via the "change" attribute on the QueueItem. The
second argument is now the Job that is about to be run, ande the
second argument is now the Job that is about to be run, and the
parameter dictionary is shifted to the third position.

* The ZUUL_SHORT_* parameters have been removed (the same
functionality may be achieved with a custom parameter function that
matches all jobs).

* Multiple triggers are now supported, in principle (though only
Gerrit is defined currently). Your layout.yaml file will need to
change to add the key "gerrit:" inside of the "triggers:" list to
specify a Gerrit trigger (and facilitate adding other kinds of
triggers later). See the sample layout.yaml.

* The default behavior is now to immediately dequeue changes that have
merge conflicts, even those not at the head of the queue. To enable
the old behavior (which would wait until the conflicting change was
Expand Down
13 changes: 13 additions & 0 deletions TESTING.rst
Expand Up @@ -67,6 +67,19 @@ List Failing Tests
.tox/py27/bin/activate
testr failing --list

Hanging Tests
-------------

The following will run each test in turn and print the name of the
test as it is run::

. .tox/py27/bin/activate
testr run --subunit | subunit2pyunit

You can compare the output of that to::

python -m testtools.run discover --list

Need More Info?
---------------

Expand Down
95 changes: 50 additions & 45 deletions doc/source/zuul.rst
Expand Up @@ -178,7 +178,8 @@ explanation of each of the parameters::
- name: check
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created
success:
verified: 1
failure:
Expand Down Expand Up @@ -253,51 +254,55 @@ explanation of each of the parameters::
DependentPipelineManager, see: :doc:`gating`.

**trigger**
This describes what Gerrit events should be placed in the pipeline.
Exactly one trigger source must be supplied for each pipeline.
Triggers are not exclusive -- matching events may be placed in
multiple pipelines, and they will behave independently in each of the
pipelines they match. Multiple triggers may be listed. Further
parameters describe the kind of events that match:

*event*
The event name from gerrit. Examples: ``patchset-created``,
``comment-added``, ``ref-updated``. This field is treated as a
regular expression.

*branch*
The branch associated with the event. Example: ``master``. This
field is treated as a regular expression, and multiple branches may
be listed.

*ref*
On ref-updated events, the branch parameter is not used, instead the
ref is provided. Currently Gerrit has the somewhat idiosyncratic
behavior of specifying bare refs for branch names (e.g., ``master``),
but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
Zuul matches what you put here exactly against what Gerrit
provides. This field is treated as a regular expression, and
multiple refs may be listed.

*approval*
This is only used for ``comment-added`` events. It only matches if
the event has a matching approval associated with it. Example:
``code-review: 2`` matches a ``+2`` vote on the code review category.
Multiple approvals may be listed.

*email_filter*
This is used for any event. It takes a regex applied on the performer
email, i.e Gerrit account email address. If you want to specify
several email filters, you must use a YAML list. Make sure to use non
greedy matchers and to escapes dots!
Example: ``email_filter: ^.*?@example\.org$``.

*comment_filter*
This is only used for ``comment-added`` events. It accepts a list of
regexes that are searched for in the comment string. If any of these
regexes matches a portion of the comment string the trigger is
matched. ``comment_filter: retrigger`` will match when comments
containing 'retrigger' somewhere in the comment text are added to a
change.
multiple pipelines, and they will behave independently in each of
the pipelines they match. You may select from the following:

**gerrit**
This describes what Gerrit events should be placed in the
pipeline. Multiple gerrit triggers may be listed. Further
parameters describe the kind of events that match:

*event*
The event name from gerrit. Examples: ``patchset-created``,
``comment-added``, ``ref-updated``. This field is treated as a
regular expression.

*branch*
The branch associated with the event. Example: ``master``. This
field is treated as a regular expression, and multiple branches may
be listed.

*ref*
On ref-updated events, the branch parameter is not used, instead the
ref is provided. Currently Gerrit has the somewhat idiosyncratic
behavior of specifying bare refs for branch names (e.g., ``master``),
but full ref names for other kinds of refs (e.g., ``refs/tags/foo``).
Zuul matches what you put here exactly against what Gerrit
provides. This field is treated as a regular expression, and
multiple refs may be listed.

*approval*
This is only used for ``comment-added`` events. It only matches if
the event has a matching approval associated with it. Example:
``code-review: 2`` matches a ``+2`` vote on the code review category.
Multiple approvals may be listed.

*email_filter*
This is used for any event. It takes a regex applied on the performer
email, i.e Gerrit account email address. If you want to specify
several email filters, you must use a YAML list. Make sure to use non
greedy matchers and to escapes dots!
Example: ``email_filter: ^.*?@example\.org$``.

*comment_filter*
This is only used for ``comment-added`` events. It accepts a list of
regexes that are searched for in the comment string. If any of these
regexes matches a portion of the comment string the trigger is
matched. ``comment_filter: retrigger`` will match when comments
containing 'retrigger' somewhere in the comment text are added to a
change.

**dequeue-on-new-patchset**
Normally, if a new patchset is uploaded to a change that is in a
Expand Down
20 changes: 12 additions & 8 deletions etc/layout.yaml-sample
Expand Up @@ -2,7 +2,8 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created
success:
verified: 1
failure:
Expand All @@ -11,8 +12,9 @@ pipelines:
- name: tests
manager: IndependentPipelineManager
trigger:
- event: patchset-created
email_filter: ^.*@example.org$
gerrit:
- event: patchset-created
email_filter: ^.*@example.org$
success:
verified: 1
failure:
Expand All @@ -21,15 +23,17 @@ pipelines:
- name: post
manager: IndependentPipelineManager
trigger:
- event: ref-updated
ref: ^(?!refs/).*$
gerrit:
- event: ref-updated
ref: ^(?!refs/).*$

- name: gate
manager: DependentPipelineManager
trigger:
- event: comment-added
approval:
- approved: 1
gerrit:
- event: comment-added
approval:
- approved: 1
start:
verified: 0
success:
Expand Down
15 changes: 9 additions & 6 deletions tests/fixtures/layout-delayed-repo-init.yaml
Expand Up @@ -2,7 +2,8 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created
success:
verified: 1
failure:
Expand All @@ -11,16 +12,18 @@ pipelines:
- name: post
manager: IndependentPipelineManager
trigger:
- event: ref-updated
ref: ^(?!refs/).*$
gerrit:
- event: ref-updated
ref: ^(?!refs/).*$

- name: gate
manager: DependentPipelineManager
failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures
trigger:
- event: comment-added
approval:
- approved: 1
gerrit:
- event: comment-added
approval:
- approved: 1
success:
verified: 2
submit: true
Expand Down
35 changes: 21 additions & 14 deletions tests/fixtures/layout.yaml
Expand Up @@ -5,7 +5,8 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created
success:
verified: 1
failure:
Expand All @@ -14,16 +15,18 @@ pipelines:
- name: post
manager: IndependentPipelineManager
trigger:
- event: ref-updated
ref: ^(?!refs/).*$
gerrit:
- event: ref-updated
ref: ^(?!refs/).*$

- name: gate
manager: DependentPipelineManager
failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures
trigger:
- event: comment-added
approval:
- approved: 1
gerrit:
- event: comment-added
approval:
- approved: 1
success:
verified: 2
submit: true
Expand All @@ -37,14 +40,16 @@ pipelines:
manager: IndependentPipelineManager
dequeue-on-new-patchset: false
trigger:
- event: comment-added
approval:
- approved: 1
gerrit:
- event: comment-added
approval:
- approved: 1

- name: dup1
manager: IndependentPipelineManager
trigger:
- event: change-restored
gerrit:
- event: change-restored
success:
verified: 1
failure:
Expand All @@ -53,7 +58,8 @@ pipelines:
- name: dup2
manager: IndependentPipelineManager
trigger:
- event: change-restored
gerrit:
- event: change-restored
success:
verified: 1
failure:
Expand All @@ -64,9 +70,10 @@ pipelines:
manager: DependentPipelineManager
failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures
trigger:
- event: comment-added
approval:
- approved: 1
gerrit:
- event: comment-added
approval:
- approved: 1
success:
verified: 2
submit: true
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/layouts/bad_pipelines4.yaml
Expand Up @@ -2,7 +2,8 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- event: non-event
gerrit:
- event: non-event

projects:
- name: foo
5 changes: 3 additions & 2 deletions tests/fixtures/layouts/bad_pipelines5.yaml
Expand Up @@ -2,8 +2,9 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- approval:
- approved: 1
gerrit:
- approval:
- approved: 1

projects:
- name: foo
5 changes: 3 additions & 2 deletions tests/fixtures/layouts/bad_pipelines6.yaml
Expand Up @@ -2,8 +2,9 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- event: comment-added
approved: 1
gerrit:
- event: comment-added
approved: 1

projects:
- name: foo
3 changes: 2 additions & 1 deletion tests/fixtures/layouts/bad_template1.yaml
Expand Up @@ -4,7 +4,8 @@ pipelines:
- name: 'check'
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created

project-templates:
- name: template-generic
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/layouts/bad_template2.yaml
Expand Up @@ -4,7 +4,8 @@ pipelines:
- name: 'check'
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created

project-templates:
- name: template-generic
Expand Down
15 changes: 9 additions & 6 deletions tests/fixtures/layouts/good_layout.yaml
Expand Up @@ -5,7 +5,8 @@ pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
- event: patchset-created
gerrit:
- event: patchset-created
success:
verified: 1
failure:
Expand All @@ -14,17 +15,19 @@ pipelines:
- name: post
manager: IndependentPipelineManager
trigger:
- event: ref-updated
ref: ^(?!refs/).*$
gerrit:
- event: ref-updated
ref: ^(?!refs/).*$

- name: gate
manager: DependentPipelineManager
success-message: Your change is awesome.
failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures
trigger:
- event: comment-added
approval:
- approved: 1
gerrit:
- event: comment-added
approval:
- approved: 1
success:
verified: 2
code-review: 1
Expand Down

0 comments on commit 6c358e7

Please sign in to comment.