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/emails | |
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/emails')
-rw-r--r-- | app/mailers/emails/pipelines.rb | 38 |
1 files changed, 38 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 |