Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
ede048b9
Commit
ede048b9
authored
Jul 12, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add project service documentation and update integration documentation
parent
8bd520d7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
78 additions
and
46 deletions
+78
-46
app/controllers/admin/services_controller.rb
app/controllers/admin/services_controller.rb
+2
-14
app/controllers/concerns/service_params.rb
app/controllers/concerns/service_params.rb
+35
-0
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+1
-16
app/helpers/services_helper.rb
app/helpers/services_helper.rb
+2
-2
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+5
-10
app/models/service.rb
app/models/service.rb
+4
-0
doc/integration/slack.md
doc/integration/slack.md
+2
-3
doc/project_services/img/slack_configuration.png
doc/project_services/img/slack_configuration.png
+0
-0
doc/project_services/project_services.md
doc/project_services/project_services.md
+1
-1
doc/project_services/slack.md
doc/project_services/slack.md
+26
-0
No files found.
app/controllers/admin/services_controller.rb
View file @
ede048b9
class
Admin::ServicesController
<
Admin
::
ApplicationController
include
ServiceParams
before_action
:service
,
only:
[
:edit
,
:update
]
def
index
...
...
@@ -37,18 +39,4 @@ class Admin::ServicesController < Admin::ApplicationController
def
service
@service
||=
Service
.
where
(
id:
params
[
:id
],
template:
true
).
first
end
def
application_services_params
dynamic_params
=
[]
dynamic_params
.
concat
(
@service
.
event_channel_names
)
if
@service
.
is_a?
(
SlackService
)
application_services_params
=
params
.
permit
(
:id
,
service:
Projects
::
ServicesController
::
ALLOWED_PARAMS
+
dynamic_params
)
if
application_services_params
[
:service
].
is_a?
(
Hash
)
Projects
::
ServicesController
::
FILTER_BLANK_PARAMS
.
each
do
|
param
|
application_services_params
[
:service
].
delete
(
param
)
if
application_services_params
[
:service
][
param
].
blank?
end
end
application_services_params
end
end
app/controllers/concerns/service_params.rb
0 → 100644
View file @
ede048b9
module
ServiceParams
extend
ActiveSupport
::
Concern
ALLOWED_PARAMS
=
[
:title
,
:token
,
:type
,
:active
,
:api_key
,
:api_url
,
:api_version
,
:subdomain
,
:room
,
:recipients
,
:project_url
,
:webhook
,
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:build_key
,
:server
,
:teamcity_url
,
:drone_url
,
:build_type
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:channel
,
:colorize_messages
,
:channels
,
:push_events
,
:issues_events
,
:merge_requests_events
,
:tag_push_events
,
:note_events
,
:build_events
,
:wiki_page_events
,
:notify_only_broken_builds
,
:add_pusher
,
:send_from_committer_email
,
:disable_diffs
,
:external_wiki_url
,
:notify
,
:color
,
:server_host
,
:server_port
,
:default_irc_uri
,
:enable_ssl_verification
,
:jira_issue_transition_id
]
# Parameters to ignore if no value is specified
FILTER_BLANK_PARAMS
=
[
:password
]
def
application_services_params
dynamic_params
=
[]
dynamic_params
.
concat
(
@service
.
event_channel_names
)
application_services_params
=
params
.
permit
(
:id
,
service:
ALLOWED_PARAMS
+
dynamic_params
)
if
application_services_params
[
:service
].
is_a?
(
Hash
)
FILTER_BLANK_PARAMS
.
each
do
|
param
|
application_services_params
[
:service
].
delete
(
param
)
if
application_services_params
[
:service
][
param
].
blank?
end
end
application_services_params
end
end
app/controllers/projects/services_controller.rb
View file @
ede048b9
class
Projects::ServicesController
<
Projects
::
ApplicationController
ALLOWED_PARAMS
=
[
:title
,
:token
,
:type
,
:active
,
:api_key
,
:api_url
,
:api_version
,
:subdomain
,
:room
,
:recipients
,
:project_url
,
:webhook
,
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:build_key
,
:server
,
:teamcity_url
,
:drone_url
,
:build_type
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:channel
,
:colorize_messages
,
:channels
,
:push_events
,
:issues_events
,
:merge_requests_events
,
:tag_push_events
,
:note_events
,
:build_events
,
:wiki_page_events
,
:notify_only_broken_builds
,
:add_pusher
,
:send_from_committer_email
,
:disable_diffs
,
:external_wiki_url
,
:notify
,
:color
,
:server_host
,
:server_port
,
:default_irc_uri
,
:enable_ssl_verification
,
:jira_issue_transition_id
]
# Parameters to ignore if no value is specified
FILTER_BLANK_PARAMS
=
[
:password
]
include
ServiceParams
# Authorize
before_action
:authorize_admin_project!
...
...
app/helpers/services_helper.rb
View file @
ede048b9
...
...
@@ -2,7 +2,7 @@ module ServicesHelper
def
service_event_description
(
event
)
case
event
when
"push"
"Webhook will triggered by a push to the repository"
"Webhook will
be
triggered by a push to the repository"
when
"tag_push"
"Webhook will be triggered when a new tag is pushed to the repository"
when
"note"
...
...
@@ -19,7 +19,7 @@ module ServicesHelper
end
def
service_event_field_name
(
event
)
event
=
event
.
pluralize
if
%w
(merge_request issue)
.
include?
(
event
)
event
=
event
.
pluralize
if
%w
[merge_request issue]
.
include?
(
event
)
"
#{
event
}
_events"
end
end
app/models/project_services/slack_service.rb
View file @
ede048b9
...
...
@@ -5,7 +5,7 @@ class SlackService < Service
def
initialize_properties
# Custom serialized properties initialization
self
.
supported_events
.
each
{
|
event
|
self
.
class
.
prop_accessor
event_channel_name
(
event
)
}
self
.
supported_events
.
each
{
|
event
|
self
.
class
.
prop_accessor
(
event_channel_name
(
event
)
)
}
if
properties
.
nil?
self
.
properties
=
{}
...
...
@@ -36,7 +36,7 @@ class SlackService < Service
[
{
type:
'text'
,
name:
'webhook'
,
placeholder:
'https://hooks.slack.com/services/...'
},
{
type:
'text'
,
name:
'username'
,
placeholder:
'username'
},
{
type:
'text'
,
name:
'channel'
,
placeholder:
"#
G
eneral"
},
{
type:
'text'
,
name:
'channel'
,
placeholder:
"#
g
eneral"
},
{
type:
'checkbox'
,
name:
'notify_only_broken_builds'
},
]
...
...
@@ -99,18 +99,13 @@ class SlackService < Service
def
get_channel_field
(
event
)
field_name
=
event_channel_name
(
event
)
self
.
send
(
field_name
)
self
.
public_
send
(
field_name
)
end
def
build_event_channels
channels
=
[]
supported_events
.
each
do
|
event
|
channel_name
=
event_channel_name
(
event
)
channels
<<
{
type:
'text'
,
name:
channel_name
,
placeholder:
"#General"
}
supported_events
.
reduce
([])
do
|
channels
,
event
|
channels
<<
{
type:
'text'
,
name:
event_channel_name
(
event
),
placeholder:
"#general"
}
end
channels
end
def
event_channel_name
(
event
)
...
...
app/models/service.rb
View file @
ede048b9
...
...
@@ -80,6 +80,10 @@ class Service < ActiveRecord::Base
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
def
event_channel_names
[]
end
def
supported_events
%w(push tag_push issue merge_request wiki_page)
end
...
...
doc/integration/slack.md
View file @
ede048b9
...
...
@@ -26,14 +26,13 @@ After Slack is ready we need to setup GitLab. Here are the steps to achieve this
1.
Navigate to Settings -> Services -> Slack
1.
Pick the triggers you want to activate
1.
Pick the triggers you want to activate
and respective channel(#general by default).
1.
Fill in your Slack details
-
Webhook: Paste the Webhook URL from the step above
-
Username: Fill this in if you want to change the username of the bot
-
Channel: Fill this in if you want to change the channel where the messages will be posted
-
Mark it as active
1.
Save your settings
Have fun :)
...
...
doc/project_services/img/slack_configuration.png
0 → 100644
View file @
ede048b9
65.8 KB
doc/project_services/project_services.md
View file @
ede048b9
...
...
@@ -45,7 +45,7 @@ further configuration instructions and details. Contributions are welcome.
| PivotalTracker | Project Management Software (Source Commits Endpoint) |
| Pushover | Pushover makes it easy to get real-time notifications on your Android device, iPhone, iPad, and Desktop |
|
[
Redmine
](
redmine.md
)
| Redmine issue tracker |
|
Slack
| A team communication tool for the 21st century |
|
[
Slack
](
slack.md
)
| A team communication tool for the 21st century |
## Services Templates
...
...
doc/project_services/slack.md
0 → 100644
View file @
ede048b9
# Slack Service
Go to your project's
**Settings > Services > Slack**
and you will see a checkbox with the following events that can be triggered:
*
Push
*
Issue
*
Merge request
*
Note
*
Tag push
*
Build
*
Wiki page
Bellow each of these event checkboxes you will have a input to insert which Slack channel do you want to send that event message,
#general channel is default.
![
Slack configuration
](
img/slack_configuration.png
)
| Field | Description |
| ----- | ----------- |
|
`Webhook`
| The incoming webhook url which you have to setup on slack. (https://my.slack.com/services/new/incoming-webhook/) |
|
`Username`
| Optional username which can be on messages sent to slack. |
|
`notify only broken builds`
| Notify only about broken builds, when build events are marked to be sent.|
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment