
When a change is uploaded as a draft, a `patchset-created` event is sent to the event stream, but since drafts are private to the owner, the event is not publicly visible. Furthermore, when the draft is later published, no publicly visible event is sent. The result of this is that external tools that rely on the event stream to detect new changes will not receive events for any changes that are first uploaded as draft. This patch adds a new event, `draft-published`, which is sent to the event stream when a draft change is published. The content of this event is the same as `patchset-created`. Bug: Issue 1437 Change-Id: I72f6dde99a82253ba796c1c13226a8b33f0e82bf
127 lines
3.7 KiB
Plaintext
127 lines
3.7 KiB
Plaintext
Gerrit Code Review - Hooks
|
|
==========================
|
|
|
|
Gerrit does not run any of the standard git hooks in the
|
|
repositories it works with, but it does have its own hook mechanism
|
|
included. Gerrit looks in `'$site_path'/hooks` for executables with
|
|
names listed below.
|
|
|
|
The environment will have GIT_DIR set to the full path of the
|
|
affected git repository so that git commands can be easily run.
|
|
|
|
Make sure your hook scripts are executable if running on *nix.
|
|
|
|
Hooks are run in the background after the relevant change has
|
|
taken place so are unable to affect the outcome of any given
|
|
change. Because of the fact the hooks are run in the background
|
|
after the activity, a hook might not be notified about an event if
|
|
the server is shutdown before the hook can be invoked.
|
|
|
|
Supported Hooks
|
|
---------------
|
|
|
|
patchset-created
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
This is called whenever a patchset is created (this includes new
|
|
changes and drafts).
|
|
|
|
====
|
|
patchset-created --change <change id> --change-url <change url> --project <project name> --branch <branch> --uploader <uploader> --commit <sha1> --patchset <patchset id>
|
|
====
|
|
|
|
draft-published
|
|
~~~~~~~~~~~~~~~
|
|
|
|
This is called whenever a draft change is published.
|
|
|
|
====
|
|
draft-published --change <change id> --change-url <change url> --project <project name> --branch <branch> --uploader <uploader> --commit <sha1> --patchset <patchset id>
|
|
====
|
|
|
|
comment-added
|
|
~~~~~~~~~~~~~
|
|
|
|
This is called whenever a comment is added to a change.
|
|
|
|
====
|
|
comment-added --change <change id> --change-url <change url> --project <project name> --branch <branch> --author <comment author> --commit <commit> --comment <comment> [--<approval category id> <score> --<approval category id> <score> ...]
|
|
====
|
|
|
|
change-merged
|
|
~~~~~~~~~~~~~
|
|
|
|
Called whenever a change has been merged.
|
|
|
|
====
|
|
change-merged --change <change id> --change-url <change url> --project <project name> --branch <branch> --submitter <submitter> --commit <sha1>
|
|
====
|
|
|
|
change-abandoned
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
Called whenever a change has been abandoned.
|
|
|
|
====
|
|
change-abandoned --change <change id> --change-url <change url> --project <project name> --branch <branch> --abandoner <abandoner> --reason <reason>
|
|
====
|
|
|
|
change-restored
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Called whenever a change has been restored.
|
|
|
|
====
|
|
change-restored --change <change id> --change-url <change url> --project <project name> --branch <branch> --restorer <restorer> --reason <reason>
|
|
====
|
|
|
|
ref-updated
|
|
~~~~~~~~~~~
|
|
|
|
Called whenever a ref has been updated.
|
|
|
|
====
|
|
ref-updated --oldrev <old rev> --newrev <new rev> --refname <ref name> --project <project name> --submitter <submitter>
|
|
====
|
|
|
|
cla-signed
|
|
~~~~~~~~~~
|
|
|
|
Called whenever a user signs a contributor license agreement.
|
|
|
|
====
|
|
cla-signed --submitter <submitter> --user-id <user_id> --cla-id <cla_id>
|
|
====
|
|
|
|
|
|
Configuration Settings
|
|
----------------------
|
|
|
|
It is possible to change where Gerrit looks for hooks, and what
|
|
filenames it looks for, by adding a [hooks] section in gerrit.config.
|
|
|
|
Gerrit will use the value of hooks.path for the hooks directory.
|
|
|
|
For the hook filenames, Gerrit will use the values of hooks.patchsetCreatedHook,
|
|
hooks.draftPublishedHook, hooks.commentAddedHook, hooks.changeMergedHook,
|
|
hooks.changeAbandonedHook, hooks.changeRestoredHook, hooks.refUpdatedHook and
|
|
hooks.claSignedHook.
|
|
|
|
Missing Change URLs
|
|
-------------------
|
|
|
|
If link:config-gerrit.html#gerrit.canonicalWebUrl[gerrit.canonicalWebUrl]
|
|
is not set in `gerrit.config` the `--change-url` flag may not be
|
|
passed to all hooks. Hooks started out of an SSH context (for example
|
|
the patchset-created hook) don't know the server's web URL, unless
|
|
this variable is configured.
|
|
|
|
See Also
|
|
--------
|
|
|
|
* link:config-gerrit.html#hooks[Section hooks]
|
|
|
|
GERRIT
|
|
------
|
|
Part of link:index.html[Gerrit Code Review]
|