David Pursehouse | 1bf7156 | 2014-12-19 13:59:40 +0900 | [diff] [blame] | 1 | = Gerrit Code Review - Plugin-based Validation |
David Pursehouse | ec31ddf | 2013-02-22 15:49:03 +0900 | [diff] [blame] | 2 | |
David Pursehouse | 1bf7156 | 2014-12-19 13:59:40 +0900 | [diff] [blame] | 3 | Gerrit provides interfaces to allow link:dev-plugins.html[plugins] to |
| 4 | perform validation on certain operations. |
David Pursehouse | ec31ddf | 2013-02-22 15:49:03 +0900 | [diff] [blame] | 5 | |
David Pursehouse | 8f9e9f5 | 2013-05-30 10:35:24 +0900 | [diff] [blame] | 6 | [[new-commit-validation]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 7 | == New commit validation |
David Pursehouse | 8f9e9f5 | 2013-05-30 10:35:24 +0900 | [diff] [blame] | 8 | |
| 9 | |
David Pursehouse | cde597d4 | 2013-05-30 10:16:17 +0900 | [diff] [blame] | 10 | Plugins implementing the `CommitValidationListener` interface can |
| 11 | perform additional validation checks against new commits. |
David Pursehouse | ec31ddf | 2013-02-22 15:49:03 +0900 | [diff] [blame] | 12 | |
David Pursehouse | cde597d4 | 2013-05-30 10:16:17 +0900 | [diff] [blame] | 13 | If the commit fails the validation, the plugin can either provide a |
| 14 | message that will be sent back to the git client, or throw an exception |
| 15 | which will cause the commit to be rejected. |
| 16 | |
| 17 | Validation applies to both commits uploaded via `git push`, and new |
| 18 | commits generated via Gerrit's Web UI features such as the rebase, revert |
| 19 | and cherry-pick buttons. |
David Pursehouse | ec31ddf | 2013-02-22 15:49:03 +0900 | [diff] [blame] | 20 | |
David Pursehouse | 9437b7b | 2012-11-05 23:48:58 +0900 | [diff] [blame] | 21 | Out of the box, Gerrit includes a plugin that checks the length of the |
| 22 | subject and body lines of commit messages on uploaded commits. |
| 23 | |
Jacek Centkowski | 0b94246 | 2014-09-10 07:53:51 -0400 | [diff] [blame] | 24 | [[user-ref-operations-validation]] |
| 25 | == User ref operations validation |
Jacek Centkowski | 6fd218d | 2014-09-10 07:42:46 -0400 | [diff] [blame] | 26 | |
| 27 | |
| 28 | Plugins implementing the `RefOperationValidationListener` interface can |
Jacek Centkowski | 0b94246 | 2014-09-10 07:53:51 -0400 | [diff] [blame] | 29 | perform additional validation checks against user ref operations (resulting |
| 30 | from either push or corresponding Gerrit REST/SSH endpoints call e.g. |
| 31 | create branch etc.). Namely including ref creation, deletion and update |
| 32 | (also non-fast-forward) before they are applied to the git repository. |
Jacek Centkowski | 6fd218d | 2014-09-10 07:42:46 -0400 | [diff] [blame] | 33 | |
Jacek Centkowski | 0b94246 | 2014-09-10 07:53:51 -0400 | [diff] [blame] | 34 | The plugin can throw an exception which will cause the operation to fail, |
| 35 | and prevent the ref update from being applied. |
Jacek Centkowski | 6fd218d | 2014-09-10 07:42:46 -0400 | [diff] [blame] | 36 | |
David Pursehouse | 8f9e9f5 | 2013-05-30 10:35:24 +0900 | [diff] [blame] | 37 | [[pre-merge-validation]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 38 | == Pre-merge validation |
David Pursehouse | 8f9e9f5 | 2013-05-30 10:35:24 +0900 | [diff] [blame] | 39 | |
| 40 | |
| 41 | Plugins implementing the `MergeValidationListener` interface can |
| 42 | perform additional validation checks against commits before they |
| 43 | are merged to the git repository. |
| 44 | |
| 45 | If the commit fails the validation, the plugin can throw an exception |
| 46 | which will cause the merge to fail. |
| 47 | |
Andrii Shyshkalov | da2034f | 2017-01-19 13:44:16 -0800 | [diff] [blame] | 48 | [[on-submit-validation]] |
| 49 | == On submit validation |
| 50 | |
| 51 | |
| 52 | Plugins implementing the `OnSubmitValidationListener` interface can |
David Pursehouse | 4b06775 | 2017-03-03 15:54:53 +0900 | [diff] [blame] | 53 | perform additional validation checks against ref operations resulting |
Andrii Shyshkalov | da2034f | 2017-01-19 13:44:16 -0800 | [diff] [blame] | 54 | from execution of submit operation before they are applied to any git |
| 55 | repositories (there could be more than one in case of topic submits). |
| 56 | |
| 57 | Plugin can throw an exception which will cause submit operation to be |
| 58 | aborted. |
| 59 | |
Hugo Arès | 0c14990 | 2014-04-17 08:35:16 -0400 | [diff] [blame] | 60 | [[pre-upload-validation]] |
| 61 | == Pre-upload validation |
| 62 | |
| 63 | |
| 64 | Plugins implementing the `UploadValidationListener` interface can |
| 65 | perform additional validation checks before any upload operations |
| 66 | (clone, fetch, pull). The validation is executed right before Gerrit |
| 67 | begins to send a pack back to the git client. |
| 68 | |
| 69 | If upload fails the validation, the plugin can throw an exception |
| 70 | which will cause the upload to fail and the exception's message text |
| 71 | will be reported to the git client. |
| 72 | |
Edwin Kempin | de3bfb2 | 2014-01-22 16:13:03 +0100 | [diff] [blame] | 73 | [[new-project-validation]] |
| 74 | == New project validation |
| 75 | |
| 76 | |
| 77 | Plugins implementing the `ProjectCreationValidationListener` interface |
| 78 | can perform additional validation on project creation based on the |
| 79 | input arguments. |
| 80 | |
| 81 | E.g. a plugin could use this to enforce a certain name scheme for |
| 82 | project names. |
| 83 | |
Edwin Kempin | 42b7b4e | 2014-01-22 20:16:20 +0100 | [diff] [blame] | 84 | [[new-group-validation]] |
| 85 | == New group validation |
| 86 | |
| 87 | |
| 88 | Plugins implementing the `GroupCreationValidationListener` interface |
| 89 | can perform additional validation on group creation based on the |
| 90 | input arguments. |
| 91 | |
| 92 | E.g. a plugin could use this to enforce a certain name scheme for |
| 93 | group names. |
| 94 | |
Gustaf Lundh | 53c26a3 | 2016-09-20 22:06:47 +0200 | [diff] [blame] | 95 | [[assignee-validation]] |
| 96 | == Assignee validation |
| 97 | |
| 98 | |
| 99 | Plugins implementing the `AssigneeValidationListener` interface can perform |
| 100 | validation of assignees before they are assigned to a change. |
| 101 | |
David Pursehouse | 1fe4ed6 | 2014-09-13 00:30:37 +0200 | [diff] [blame] | 102 | [[hashtag-validation]] |
| 103 | == Hashtag validation |
| 104 | |
| 105 | |
| 106 | Plugins implementing the `HashtagValidationListener` interface can perform |
| 107 | validation of hashtags before they are added to or removed from changes. |
| 108 | |
Zalan Blenessy | 81671c9 | 2014-12-23 11:42:28 +0100 | [diff] [blame] | 109 | [[outgoing-email-validation]] |
| 110 | == Outgoing e-mail validation |
| 111 | |
| 112 | |
| 113 | This interface provides a low-level e-mail filtering API for plugins. |
| 114 | Plugins implementing the `OutgoingEmailValidationListener` interface can perform |
| 115 | filtering of outgoing e-mails just before they are sent. |
| 116 | |
Edwin Kempin | f0d71a8 | 2018-04-20 13:03:34 +0200 | [diff] [blame] | 117 | [[account-activation-validation]] |
| 118 | == Account activation validation |
| 119 | |
| 120 | |
| 121 | Plugins implementing the `AccountActivationValidationListener` interface can |
| 122 | perform validation when an account is activated or deactivated via the Gerrit |
| 123 | REST API or the Java extension API. |
| 124 | |
Joerg Zieren | 81c899f | 2019-07-24 17:39:26 +0200 | [diff] [blame] | 125 | [[review-comment-validation]] |
| 126 | == Review comment validation |
| 127 | |
| 128 | |
| 129 | The `CommentValidator` interface allows plugins to validate all review comments, |
| 130 | i.e. inline comments, file comments and the review message. This works for the |
| 131 | REST API, for `git push` when `--publish-comments` is used and for comments sent |
| 132 | via email. |
| 133 | |
David Pursehouse | ec31ddf | 2013-02-22 15:49:03 +0900 | [diff] [blame] | 134 | |
| 135 | GERRIT |
| 136 | ------ |
| 137 | Part of link:index.html[Gerrit Code Review] |
| 138 | |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 139 | |
| 140 | SEARCHBOX |
| 141 | --------- |