diff options
Diffstat (limited to 'app/mailers/emails/pipelines.rb')
-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 |