diff options
author | Evan Read <eread@gitlab.com> | 2019-08-05 21:24:33 +0000 |
---|---|---|
committer | Evan Read <eread@gitlab.com> | 2019-08-05 21:24:33 +0000 |
commit | 0555bc64b8a4e7ae910ea5ab6754a83435bc52d8 (patch) | |
tree | 76fedf93e39c157bbe4e6afb04ad96b35a6a93b9 /doc/administration/plugins.md | |
parent | baaba23f9a21df4eb5cbc7c2468be5abcfe3aa87 (diff) | |
parent | 79a39a5c5543331cdd54f95fdfd323006fa9fcd2 (diff) | |
download | gitlab-ce-0555bc64b8a4e7ae910ea5ab6754a83435bc52d8.tar.gz |
Merge branch 'rz_extend_plugins' into 'master'
Add example to plugins file
See merge request gitlab-org/gitlab-ce!30508
Diffstat (limited to 'doc/administration/plugins.md')
-rw-r--r-- | doc/administration/plugins.md | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/doc/administration/plugins.md b/doc/administration/plugins.md index 4302667caf5..4cf3c607dae 100644 --- a/doc/administration/plugins.md +++ b/doc/administration/plugins.md @@ -52,7 +52,37 @@ as appropriate. The plugins file list is updated for each event, there is no need to restart GitLab to apply a new plugin. If a plugin executes with non-zero exit code or GitLab fails to execute it, a -message will be logged to `plugin.log`. +message will be logged to: + +- `gitlab-rails/plugin.log` in an Omnibus installation. +- `log/plugin.log` in a source installation. + +## Creating plugins + +Below is an example that will only response on the event `project_create` and +will inform the admins from the GitLab instance that a new project has been created. + +```ruby +# By using the embedded ruby version we eliminate the possibility that our chosen language +# would be unavailable from +#!/opt/gitlab/embedded/bin/ruby +require 'json' +require 'mail' + +# The incoming variables are in JSON format so we need to parse it first. +ARGS = JSON.parse(STDIN.read) + +# We only want to trigger this plugin on the event project_create +return unless ARGS['event_name'] == 'project_create' + +# We will inform our admins of our gitlab instance that a new project is created +Mail.deliver do + from 'info@gitlab_instance.com' + to 'admin@gitlab_instance.com' + subject "new project " + ARGS['name'] + body ARGS['owner_name'] + 'created project ' + ARGS['name'] +end +``` ## Validation |