diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-25 20:01:10 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-26 16:56:55 +0800 |
commit | 34cbc51e238a6b1626ef3d656b2dc80db6463971 (patch) | |
tree | 9ab4f2b6f8862f12d1e5235ec691d46667e73eab /app/mailers | |
parent | 7bbb523b23638c52b3c0ba43d8f3dbef8840aad6 (diff) | |
download | gitlab-ce-34cbc51e238a6b1626ef3d656b2dc80db6463971.tar.gz |
Add a new pipeline email service. TODO: email templates and tests
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/emails/pipelines.rb | 38 | ||||
-rw-r--r-- | app/mailers/notify.rb | 1 |
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 |