diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-14 19:42:16 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-17 07:24:48 +0000 |
commit | 8ea702cfe590e94ea496609f85ba0f23bda2dcce (patch) | |
tree | b5aef28ad58ae357b0cdce8651f76710fb69439f /app | |
parent | 7f7c3e1a8aeba5d21c332c8cacdf8af9067199c4 (diff) | |
download | gitlab-ce-8ea702cfe590e94ea496609f85ba0f23bda2dcce.tar.gz |
Revert "Split notification integration into another branch"
This reverts commit 1404aa8677969a03ed56e8f8350257f317f576d8.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/pipeline.rb | 9 | ||||
-rw-r--r-- | app/models/notification_setting.rb | 4 | ||||
-rw-r--r-- | app/services/ci/send_pipeline_notification_service.rb | 10 | ||||
-rw-r--r-- | app/services/notification_service.rb | 16 |
4 files changed, 30 insertions, 9 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 4fdb5fef4fb..c293096f5c9 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -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)") diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb index 121b598b8f3..43fc218de2b 100644 --- a/app/models/notification_setting.rb +++ b/app/models/notification_setting.rb @@ -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 diff --git a/app/services/ci/send_pipeline_notification_service.rb b/app/services/ci/send_pipeline_notification_service.rb index ceb182801f7..cfbcad5dadf 100644 --- a/app/services/ci/send_pipeline_notification_service.rb +++ b/app/services/ci/send_pipeline_notification_service.rb @@ -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 diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 72712afc07e..65091c2b8af 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -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 |