Skip to content

Commit 0555bc6

Browse files
committed
Merge branch 'rz_extend_plugins' into 'master'
Add example to plugins file See merge request gitlab-org/gitlab-ce!30508
2 parents baaba23 + 79a39a5 commit 0555bc6

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

doc/administration/plugins.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,37 @@ as appropriate. The plugins file list is updated for each event, there is no
5252
need to restart GitLab to apply a new plugin.
5353

5454
If a plugin executes with non-zero exit code or GitLab fails to execute it, a
55-
message will be logged to `plugin.log`.
55+
message will be logged to:
56+
57+
- `gitlab-rails/plugin.log` in an Omnibus installation.
58+
- `log/plugin.log` in a source installation.
59+
60+
## Creating plugins
61+
62+
Below is an example that will only response on the event `project_create` and
63+
will inform the admins from the GitLab instance that a new project has been created.
64+
65+
```ruby
66+
# By using the embedded ruby version we eliminate the possibility that our chosen language
67+
# would be unavailable from
68+
#!/opt/gitlab/embedded/bin/ruby
69+
require 'json'
70+
require 'mail'
71+
72+
# The incoming variables are in JSON format so we need to parse it first.
73+
ARGS = JSON.parse(STDIN.read)
74+
75+
# We only want to trigger this plugin on the event project_create
76+
return unless ARGS['event_name'] == 'project_create'
77+
78+
# We will inform our admins of our gitlab instance that a new project is created
79+
Mail.deliver do
80+
from 'info@gitlab_instance.com'
81+
to 'admin@gitlab_instance.com'
82+
subject "new project " + ARGS['name']
83+
body ARGS['owner_name'] + 'created project ' + ARGS['name']
84+
end
85+
```
5686

5787
## Validation
5888

0 commit comments

Comments
 (0)