blob: cb953c128887c4f5c2bfc9427a1b751b9c7d36ed [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
Jacek Centkowski0b942462014-09-10 07:53:51 -040024[[user-ref-operations-validation]]
25== User ref operations validation
Jacek Centkowski6fd218d2014-09-10 07:42:46 -040026
27
28Plugins implementing the `RefOperationValidationListener` interface can
Jacek Centkowski0b942462014-09-10 07:53:51 -040029perform additional validation checks against user ref operations (resulting
30from either push or corresponding Gerrit REST/SSH endpoints call e.g.
31create branch etc.). Namely including ref creation, deletion and update
32(also non-fast-forward) before they are applied to the git repository.
Jacek Centkowski6fd218d2014-09-10 07:42:46 -040033
Jacek Centkowski0b942462014-09-10 07:53:51 -040034The plugin can throw an exception which will cause the operation to fail,
35and prevent the ref update from being applied.
Jacek Centkowski6fd218d2014-09-10 07:42:46 -040036
David Pursehouse8f9e9f52013-05-30 10:35:24 +090037[[pre-merge-validation]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080038== Pre-merge validation
David Pursehouse8f9e9f52013-05-30 10:35:24 +090039
40
41Plugins implementing the `MergeValidationListener` interface can
42perform additional validation checks against commits before they
43are merged to the git repository.
44
45If the commit fails the validation, the plugin can throw an exception
46which will cause the merge to fail.
47
Andrii Shyshkalovda2034f2017-01-19 13:44:16 -080048[[on-submit-validation]]
49== On submit validation
50
51
52Plugins implementing the `OnSubmitValidationListener` interface can
David Pursehouse4b067752017-03-03 15:54:53 +090053perform additional validation checks against ref operations resulting
Andrii Shyshkalovda2034f2017-01-19 13:44:16 -080054from execution of submit operation before they are applied to any git
55repositories (there could be more than one in case of topic submits).
56
57Plugin can throw an exception which will cause submit operation to be
58aborted.
59
Hugo Arès0c149902014-04-17 08:35:16 -040060[[pre-upload-validation]]
61== Pre-upload validation
62
63
64Plugins implementing the `UploadValidationListener` interface can
65perform additional validation checks before any upload operations
66(clone, fetch, pull). The validation is executed right before Gerrit
67begins to send a pack back to the git client.
68
69If upload fails the validation, the plugin can throw an exception
70which will cause the upload to fail and the exception's message text
71will be reported to the git client.
72
Edwin Kempinde3bfb22014-01-22 16:13:03 +010073[[new-project-validation]]
74== New project validation
75
76
77Plugins implementing the `ProjectCreationValidationListener` interface
78can perform additional validation on project creation based on the
79input arguments.
80
81E.g. a plugin could use this to enforce a certain name scheme for
82project names.
83
Edwin Kempin42b7b4e2014-01-22 20:16:20 +010084[[new-group-validation]]
85== New group validation
86
87
88Plugins implementing the `GroupCreationValidationListener` interface
89can perform additional validation on group creation based on the
90input arguments.
91
92E.g. a plugin could use this to enforce a certain name scheme for
93group names.
94
Gustaf Lundh53c26a32016-09-20 22:06:47 +020095[[assignee-validation]]
96== Assignee validation
97
98
99Plugins implementing the `AssigneeValidationListener` interface can perform
100validation of assignees before they are assigned to a change.
101
David Pursehouse1fe4ed62014-09-13 00:30:37 +0200102[[hashtag-validation]]
103== Hashtag validation
104
105
106Plugins implementing the `HashtagValidationListener` interface can perform
107validation of hashtags before they are added to or removed from changes.
108
Zalan Blenessy81671c92014-12-23 11:42:28 +0100109[[outgoing-email-validation]]
110== Outgoing e-mail validation
111
112
113This interface provides a low-level e-mail filtering API for plugins.
114Plugins implementing the `OutgoingEmailValidationListener` interface can perform
115filtering of outgoing e-mails just before they are sent.
116
Edwin Kempinf0d71a82018-04-20 13:03:34 +0200117[[account-activation-validation]]
118== Account activation validation
119
120
121Plugins implementing the `AccountActivationValidationListener` interface can
122perform validation when an account is activated or deactivated via the Gerrit
123REST API or the Java extension API.
124
Joerg Zieren81c899f2019-07-24 17:39:26 +0200125[[review-comment-validation]]
126== Review comment validation
127
128
129The `CommentValidator` interface allows plugins to validate all review comments,
130i.e. inline comments, file comments and the review message. This works for the
131REST API, for `git push` when `--publish-comments` is used and for comments sent
132via email.
133
David Pursehouseec31ddf2013-02-22 15:49:03 +0900134
135GERRIT
136------
137Part of link:index.html[Gerrit Code Review]
138
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700139
140SEARCHBOX
141---------