blob: 56c9ecdc017ace14b782786a04108ab8df0bb502 [file] [log] [blame]
David Pursehouse1bf71562014-12-19 13:59:40 +09001= Gerrit Code Review - Plugin-based Validation
David Pursehouseec31ddf2013-02-22 15:49:03 +09002
David Pursehouse1bf71562014-12-19 13:59:40 +09003Gerrit provides interfaces to allow link:dev-plugins.html[plugins] to
4perform validation on certain operations.
David Pursehouseec31ddf2013-02-22 15:49:03 +09005
David Pursehouse8f9e9f52013-05-30 10:35:24 +09006[[new-commit-validation]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08007== New commit validation
David Pursehouse8f9e9f52013-05-30 10:35:24 +09008
9
David Pursehousecde597d42013-05-30 10:16:17 +090010Plugins implementing the `CommitValidationListener` interface can
11perform additional validation checks against new commits.
David Pursehouseec31ddf2013-02-22 15:49:03 +090012
David Pursehousecde597d42013-05-30 10:16:17 +090013If the commit fails the validation, the plugin can either provide a
14message that will be sent back to the git client, or throw an exception
15which will cause the commit to be rejected.
16
17Validation applies to both commits uploaded via `git push`, and new
18commits generated via Gerrit's Web UI features such as the rebase, revert
19and cherry-pick buttons.
David Pursehouseec31ddf2013-02-22 15:49:03 +090020
David Pursehouse9437b7b2012-11-05 23:48:58 +090021Out of the box, Gerrit includes a plugin that checks the length of the
22subject and body lines of commit messages on uploaded commits.
23
Edwin Kempin0b400596c2021-03-12 14:37:01 +010024[plugin-push-options]]
25=== Plugin push options
26
27Plugins can register push options by implementing the `PluginPushOption`
28interface. If a plugin push option was specified it is available from
29the `CommitReceivedEvent` that is passed into `CommitValidationListener`.
30This way the plugin commit validation can be controlled by push options.
31
Jacek Centkowski0b942462014-09-10 07:53:51 -040032[[user-ref-operations-validation]]
33== User ref operations validation
Jacek Centkowski6fd218d2014-09-10 07:42:46 -040034
35
36Plugins implementing the `RefOperationValidationListener` interface can
Jacek Centkowski0b942462014-09-10 07:53:51 -040037perform additional validation checks against user ref operations (resulting
38from either push or corresponding Gerrit REST/SSH endpoints call e.g.
39create branch etc.). Namely including ref creation, deletion and update
40(also non-fast-forward) before they are applied to the git repository.
Jacek Centkowski6fd218d2014-09-10 07:42:46 -040041
Jacek Centkowski0b942462014-09-10 07:53:51 -040042The plugin can throw an exception which will cause the operation to fail,
43and prevent the ref update from being applied.
Jacek Centkowski6fd218d2014-09-10 07:42:46 -040044
David Pursehouse8f9e9f52013-05-30 10:35:24 +090045[[pre-merge-validation]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080046== Pre-merge validation
David Pursehouse8f9e9f52013-05-30 10:35:24 +090047
48
49Plugins implementing the `MergeValidationListener` interface can
50perform additional validation checks against commits before they
51are merged to the git repository.
52
53If the commit fails the validation, the plugin can throw an exception
54which will cause the merge to fail.
55
Andrii Shyshkalovda2034f2017-01-19 13:44:16 -080056[[on-submit-validation]]
57== On submit validation
58
59
60Plugins implementing the `OnSubmitValidationListener` interface can
David Pursehouse4b067752017-03-03 15:54:53 +090061perform additional validation checks against ref operations resulting
Andrii Shyshkalovda2034f2017-01-19 13:44:16 -080062from execution of submit operation before they are applied to any git
63repositories (there could be more than one in case of topic submits).
64
65Plugin can throw an exception which will cause submit operation to be
66aborted.
67
Hugo Arès0c149902014-04-17 08:35:16 -040068[[pre-upload-validation]]
69== Pre-upload validation
70
71
72Plugins implementing the `UploadValidationListener` interface can
73perform additional validation checks before any upload operations
74(clone, fetch, pull). The validation is executed right before Gerrit
75begins to send a pack back to the git client.
76
77If upload fails the validation, the plugin can throw an exception
78which will cause the upload to fail and the exception's message text
79will be reported to the git client.
80
Edwin Kempinde3bfb22014-01-22 16:13:03 +010081[[new-project-validation]]
82== New project validation
83
84
85Plugins implementing the `ProjectCreationValidationListener` interface
86can perform additional validation on project creation based on the
87input arguments.
88
89E.g. a plugin could use this to enforce a certain name scheme for
90project names.
91
Edwin Kempin42b7b4e2014-01-22 20:16:20 +010092[[new-group-validation]]
93== New group validation
94
95
96Plugins implementing the `GroupCreationValidationListener` interface
97can perform additional validation on group creation based on the
98input arguments.
99
100E.g. a plugin could use this to enforce a certain name scheme for
101group names.
102
Gustaf Lundh53c26a32016-09-20 22:06:47 +0200103[[assignee-validation]]
104== Assignee validation
105
106
107Plugins implementing the `AssigneeValidationListener` interface can perform
108validation of assignees before they are assigned to a change.
109
David Pursehouse1fe4ed62014-09-13 00:30:37 +0200110[[hashtag-validation]]
111== Hashtag validation
112
113
114Plugins implementing the `HashtagValidationListener` interface can perform
115validation of hashtags before they are added to or removed from changes.
116
Zalan Blenessy81671c92014-12-23 11:42:28 +0100117[[outgoing-email-validation]]
118== Outgoing e-mail validation
119
120
121This interface provides a low-level e-mail filtering API for plugins.
122Plugins implementing the `OutgoingEmailValidationListener` interface can perform
123filtering of outgoing e-mails just before they are sent.
124
Edwin Kempinf0d71a82018-04-20 13:03:34 +0200125[[account-activation-validation]]
126== Account activation validation
127
128
129Plugins implementing the `AccountActivationValidationListener` interface can
130perform validation when an account is activated or deactivated via the Gerrit
131REST API or the Java extension API.
132
Joerg Zieren81c899f2019-07-24 17:39:26 +0200133[[review-comment-validation]]
134== Review comment validation
135
136
137The `CommentValidator` interface allows plugins to validate all review comments,
138i.e. inline comments, file comments and the review message. This works for the
139REST API, for `git push` when `--publish-comments` is used and for comments sent
140via email.
141
David Pursehouseec31ddf2013-02-22 15:49:03 +0900142
143GERRIT
144------
145Part of link:index.html[Gerrit Code Review]
146
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700147
148SEARCHBOX
149---------