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
Boxiang Sun
gitlab-ce
Commits
8ea702cf
Commit
8ea702cf
authored
Sep 14, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Split notification integration into another branch"
This reverts commit
1404aa86
.
parent
7f7c3e1a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
10 deletions
+31
-10
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+9
-0
app/models/notification_setting.rb
app/models/notification_setting.rb
+3
-1
app/services/ci/send_pipeline_notification_service.rb
app/services/ci/send_pipeline_notification_service.rb
+2
-8
app/services/notification_service.rb
app/services/notification_service.rb
+16
-0
spec/services/ci/send_pipeline_notification_service_spec.rb
spec/services/ci/send_pipeline_notification_service_spec.rb
+1
-1
No files found.
app/models/ci/pipeline.rb
View file @
8ea702cf
...
...
@@ -82,6 +82,10 @@ module Ci
PipelineHooksWorker
.
perform_async
(
id
)
end
end
after_transition
any
=>
[
:success
,
:failed
]
do
|
pipeline
,
transition
|
SendPipelineNotificationService
.
new
(
pipeline
).
execute
end
end
# ref can't be HEAD or SHA, can only be branch/tag name
...
...
@@ -110,6 +114,11 @@ module Ci
project
.
id
end
# For now the only user who participants is the user who triggered
def
participants
(
current_user
=
nil
)
[
user
]
end
def
valid_commit_sha
if
self
.
sha
==
Gitlab
::
Git
::
BLANK_SHA
self
.
errors
.
add
(
:sha
,
" cant be 00000000 (branch removal)"
)
...
...
app/models/notification_setting.rb
View file @
8ea702cf
...
...
@@ -32,7 +32,9 @@ class NotificationSetting < ActiveRecord::Base
:reopen_merge_request
,
:close_merge_request
,
:reassign_merge_request
,
:merge_merge_request
:merge_merge_request
,
:failed_pipeline
,
:success_pipeline
]
store
:events
,
accessors:
EMAIL_EVENTS
,
coder:
JSON
...
...
app/services/ci/send_pipeline_notification_service.rb
View file @
8ea702cf
...
...
@@ -6,14 +6,8 @@ module Ci
@pipeline
=
new_pipeline
end
def
execute
(
recipients
)
email_template
=
"pipeline_
#{
pipeline
.
status
}
_email"
return
unless
Notify
.
respond_to?
(
email_template
)
recipients
.
each
do
|
to
|
Notify
.
public_send
(
email_template
,
pipeline
,
to
).
deliver_later
end
def
execute
(
recipients
=
nil
)
notification_service
.
pipeline_finished
(
pipeline
,
recipients
)
end
end
end
app/services/notification_service.rb
View file @
8ea702cf
...
...
@@ -312,6 +312,22 @@ class NotificationService
mailer
.
project_was_not_exported_email
(
current_user
,
project
,
errors
).
deliver_later
end
def
pipeline_finished
(
pipeline
,
recipients
=
nil
)
email_template
=
"pipeline_
#{
pipeline
.
status
}
_email"
return
unless
mailer
.
respond_to?
(
email_template
)
recipients
||=
build_recipients
(
pipeline
,
pipeline
.
project
,
nil
,
# The acting user, who won't be added to recipients
action:
pipeline
.
status
)
recipients
.
each
do
|
to
|
mailer
.
public_send
(
email_template
,
pipeline
,
to
.
email
).
deliver_later
end
end
protected
# Get project/group users with CUSTOM notification level
...
...
spec/services/ci/send_pipeline_notification_service_spec.rb
View file @
8ea702cf
...
...
@@ -23,7 +23,7 @@ describe Ci::SendPipelineNotificationService, services: true do
shared_examples
'sending emails'
do
it
'sends emails'
do
perform_enqueued_jobs
do
subject
.
execute
([
user
.
email
])
subject
.
execute
end
expected_receivers
=
[
pusher
,
watcher
].
uniq
.
sort_by
(
&
:email
)
...
...
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