diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index b9c46202e5e3cf6b3188c606d75e9e883e4466b4..0b1df9f429423b6940ff8e18257a7efa9c2601a4 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -62,10 +62,6 @@ module Ci after_transition do |pipeline, transition| pipeline.execute_hooks unless transition.loopback? 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 @@ -94,11 +90,6 @@ 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 43fc218de2b5d458ab85add171d173ab8d2c0880..121b598b8f3839f67a9963bc31dfb3ad9b79f597 100644 --- a/app/models/notification_setting.rb +++ b/app/models/notification_setting.rb @@ -32,9 +32,7 @@ class NotificationSetting < ActiveRecord::Base :reopen_merge_request, :close_merge_request, :reassign_merge_request, - :merge_merge_request, - :failed_pipeline, - :success_pipeline + :merge_merge_request ] 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 d330fa1a73c2324634d8de82cbbd443c7f4c222e..db462fe0291ff44c39759ca91777263d933fbd8e 100644 --- a/app/services/ci/send_pipeline_notification_service.rb +++ b/app/services/ci/send_pipeline_notification_service.rb @@ -6,8 +6,14 @@ module Ci @pipeline = new_pipeline end - def execute(recipients = nil) - notification_service.pipeline_finished(pipeline, recipients) + 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 end end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 9ce06b69e9d1598a7308f3aab092d72964052a13..0479a41b6a569541376d4d00ff50a880b6393c5c 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -311,22 +311,6 @@ 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 diff --git a/spec/services/ci/send_pipeline_notification_service_spec.rb b/spec/services/ci/send_pipeline_notification_service_spec.rb index ba588ed8ef534e963d8eddfdd407b726c0498a65..cb53ba8b051546590e07bff46c001857951216e3 100644 --- a/spec/services/ci/send_pipeline_notification_service_spec.rb +++ b/spec/services/ci/send_pipeline_notification_service_spec.rb @@ -9,7 +9,7 @@ describe Ci::SendPipelineNotificationService, services: true do shared_examples 'sending emails' do it 'sends an email to pipeline user' do perform_enqueued_jobs do - subject.execute + subject.execute([user.email]) end email = ActionMailer::Base.deliveries.last