Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-25 15:01:10 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-08-26 11:56:55 +0300
commit34cbc51e238a6b1626ef3d656b2dc80db6463971 (patch)
tree9ab4f2b6f8862f12d1e5235ec691d46667e73eab /app/mailers
parent7bbb523b23638c52b3c0ba43d8f3dbef8840aad6 (diff)
Add a new pipeline email service. TODO: email templates and tests
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/emails/pipelines.rb38
-rw-r--r--app/mailers/notify.rb1
2 files changed, 39 insertions, 0 deletions
diff --git a/app/mailers/emails/pipelines.rb b/app/mailers/emails/pipelines.rb
new file mode 100644
index 00000000000..7fdba850219
--- /dev/null
+++ b/app/mailers/emails/pipelines.rb
@@ -0,0 +1,38 @@
+module Emails
+ module Pipelines
+ def pipeline_succeeded_email(params, to)
+ pipeline_mail(params, to, 'succeeded') # TODO: missing template
+ end
+
+ def pipeline_failed_email(params, to)
+ pipeline_mail(params, to, 'failed') # TODO: missing template
+ end
+
+ private
+
+ def pipeline_mail(params, to, status)
+ @params = params
+ add_headers
+
+ mail(to: to, subject: pipeline_subject('failed'))
+ end
+
+ def add_headers
+ @project = @params.project # `add_project_headers` needs this
+ add_project_headers
+ add_pipeline_headers(@params.pipeline)
+ end
+
+ def add_pipeline_headers(pipeline)
+ headers['X-GitLab-Pipeline-Id'] = pipeline.id
+ headers['X-GitLab-Pipeline-Ref'] = pipeline.ref
+ headers['X-GitLab-Pipeline-Status'] = pipeline.status
+ end
+
+ def pipeline_subject(status)
+ subject(
+ "Pipeline #{status} for #{@params.project.name}",
+ @params.pipeline.short_sha)
+ end
+ end
+end
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 0cc709f68e4..fef8149b325 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -7,6 +7,7 @@ class Notify < BaseMailer
include Emails::Projects
include Emails::Profile
include Emails::Builds
+ include Emails::Pipelines
include Emails::Members
add_template_helper MergeRequestsHelper