Method: NotificationService#pipeline_finished

Defined in:
app/services/notification_service.rb

#pipeline_finished(pipeline, ref_status: nil, recipients: nil) ⇒ Object



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'app/services/notification_service.rb', line 562

def pipeline_finished(pipeline, ref_status: nil, recipients: nil)
  # Must always check project configuration since recipients could be a list of emails
  # from the PipelinesEmailService integration.
  return if pipeline.project.emails_disabled?

  # If changing the next line don't forget to do the same in EE section
  status = pipeline_notification_status(ref_status, pipeline)
  email_template = email_template_name(status)

  return unless mailer.respond_to?(email_template)

  recipients ||= notifiable_users(
    [pipeline.user], :watch,
    custom_action: :"#{status}_pipeline",
    target: pipeline
  ).map do |user|
    user.notification_email_for(pipeline.project.group)
  end

  recipients.each do |recipient|
    mailer.public_send(email_template, pipeline, recipient).deliver_later
  end
end