diff options
author | Luke Duncalfe <lduncalfe@eml.cc> | 2019-03-20 17:08:51 +1300 |
---|---|---|
committer | Luke Duncalfe <lduncalfe@eml.cc> | 2019-03-26 13:05:40 +1300 |
commit | f82380b9df9693e7976b7474233840a469635429 (patch) | |
tree | 0b692684c7b5933d3df6076ec5b9c9e772dd6a50 /doc/administration/custom_hooks.md | |
parent | a3b3da72775fd37f7533ddd88fe47600079b4ed9 (diff) | |
download | gitlab-ce-f82380b9df9693e7976b7474233840a469635429.tar.gz |
Allow custom hooks errors to appear in GitLab UI
Error messages from custom pre-receive hooks now appear in the GitLab
UI.
This is re-enabling a feature that had been disabled in merge request
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18646
The feature had been disabled due to security concerns that information
which was not intended to be public (like stack traces) would leak into
public view.
PreReceiveErrors (from pre-receive, post-receive and update custom
hooks) are now filtered for messages that have been prefixed in a
particular way.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/48132
Diffstat (limited to 'doc/administration/custom_hooks.md')
-rw-r--r-- | doc/administration/custom_hooks.md | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/doc/administration/custom_hooks.md b/doc/administration/custom_hooks.md index 60ad4bf4e8f..28afaf84f5a 100644 --- a/doc/administration/custom_hooks.md +++ b/doc/administration/custom_hooks.md @@ -51,7 +51,7 @@ Hooks can be also placed in `hooks/<hook_name>.d` (global) or execution of the hooks. NOTE: **Note:** `<hook_name>.d` would need to be either `pre-receive.d`, -`post-receive.d`, or `update.d` to work properly. Any other names will be ignored. +`post-receive.d`, or `update.d` to work properly. Any other names will be ignored. To look in a different directory for the global custom hooks (those in `hooks/<hook_name.d>`), set `custom_hooks_dir` in gitlab-shell config. For @@ -76,9 +76,21 @@ first script exiting with a non-zero value. > [Introduced][5073] in GitLab 8.10. -If the commit is declined or an error occurs during the Git hook check, -the STDERR or STDOUT message of the hook will be present in GitLab's UI. -STDERR takes precedence over STDOUT. +To have custom error messages appear in GitLab's UI when the commit is +declined or an error occurs during the Git hook, your script should: + +- Send the custom error messages to either the script's `stdout` or `stderr`. +- Prefix each message with `GL-HOOK-ERR:` with no characters appearing before the prefix. + +### Example custom error message + +This hook script written in bash will generate the following message in GitLab's UI: + +```bash +#!/bin/sh +echo "GL-HOOK-ERR: My custom error message."; +exit 1 +``` ![Custom message from custom Git hook](img/custom_hooks_error_msg.png) |