Ben Rohlfs | ab7fbbf | 2021-04-29 10:27:03 +0200 | [diff] [blame] | 1 | :linkattrs: |
| 2 | = Gerrit Code Review - JavaScript Plugin Checks API |
| 3 | |
| 4 | This API is provided by link:pg-plugin-dev.html#plugin-checks[plugin.checks()]. |
| 5 | It allows plugins to contribute to the "Checks" tab and summary: |
| 6 | |
| 7 | image::images/user-checks-overview.png[width=800] |
| 8 | |
| 9 | Each plugin can link:#register[register] a checks provider that will be called |
| 10 | when a change page is loaded. Such a call would return a list of `Runs` and each |
| 11 | run can contain a list of `Results`. |
| 12 | |
| 13 | The details of the ChecksApi are documented in the |
| 14 | link:https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/app/api/checks.ts[source code]. |
| 15 | Note that this link points to the `master` branch and might thus reflect a |
| 16 | newer version of the API than your Gerrit installation. |
| 17 | |
| 18 | If no plugins are registered with the ChecksApi, then the Checks tab will be |
| 19 | hidden. |
| 20 | |
| 21 | You can read about the motivation, the use cases and the original plans in the |
| 22 | link:https://www.gerritcodereview.com/design-docs/ci-reboot.html[design doc]. |
| 23 | |
| 24 | Here are some examples of open source plugins that make use of the Checks API: |
| 25 | |
| 26 | * link:https://gerrit.googlesource.com/plugins/checks/+/master/gr-checks/plugin.js[Gerrit Checks Plugin] |
| 27 | * link:https://chromium.googlesource.com/infra/gerrit-plugins/buildbucket/+/master/src/main/resources/static/buildbucket.js[Chromium Buildbucket Plugin] |
| 28 | * link:https://chromium.googlesource.com/infra/gerrit-plugins/code-coverage/+/master/src/main/resources/static/chromium-coverage.js[Chromium Coverage Plugin] |
| 29 | |
| 30 | [[register]] |
| 31 | == register |
| 32 | `checksApi.register(provider, config?)` |
| 33 | |
| 34 | .Params |
| 35 | - *provider* Must implement a `fetch()` interface that returns a |
| 36 | `Promise<FetchResponse>` with runs and results. See also documentation in the |
| 37 | link:https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/app/api/checks.ts[source code]. |
| 38 | - *config* Optional configuration values for the checks provider. |
| 39 | |
| 40 | [[announceUpdate]] |
| 41 | == announceUpdate |
| 42 | `checksApi.announceUpdate()` |
| 43 | |
| 44 | Tells Gerrit to call `provider.fetch()`. |