Add mock email templates
This commit is contained in:
parent
0997cfd750
commit
1bd2327c31
7 changed files with 106 additions and 11 deletions
|
@ -11,28 +11,27 @@ module Emails
|
|||
private
|
||||
|
||||
def pipeline_mail(params, to, status)
|
||||
@params = params
|
||||
@project = params.project
|
||||
@pipeline = params.pipeline
|
||||
add_headers
|
||||
|
||||
mail(to: to, subject: pipeline_subject(status))
|
||||
end
|
||||
|
||||
def add_headers
|
||||
@project = @params.project # `add_project_headers` needs this
|
||||
add_project_headers
|
||||
add_pipeline_headers(@params.pipeline)
|
||||
add_pipeline_headers
|
||||
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
|
||||
def add_pipeline_headers
|
||||
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)
|
||||
"Pipeline #{status} for #{@project.name}", @pipeline.short_sha)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -133,8 +133,11 @@ module Ci
|
|||
end
|
||||
|
||||
def trace_with_state(state = nil)
|
||||
trace_with_state = Ci::Ansi2html::convert(trace, state) if trace.present?
|
||||
trace_with_state || {}
|
||||
if trace.present?
|
||||
Ci::Ansi2html.convert(trace, state)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def timeout
|
||||
|
|
|
@ -198,6 +198,7 @@ class Service < ActiveRecord::Base
|
|||
bamboo
|
||||
buildkite
|
||||
builds_email
|
||||
pipelines_email
|
||||
bugzilla
|
||||
campfire
|
||||
custom_issue_tracker
|
||||
|
|
44
app/views/notify/pipeline_failed_email.html.haml
Normal file
44
app/views/notify/pipeline_failed_email.html.haml
Normal file
|
@ -0,0 +1,44 @@
|
|||
.p
|
||||
Project:
|
||||
= @project.path_with_namespace
|
||||
.p
|
||||
Branch:
|
||||
= @pipeline.ref
|
||||
.p
|
||||
Commit:
|
||||
= @pipeline.short_sha
|
||||
(
|
||||
= @pipeline.sha
|
||||
)
|
||||
.p
|
||||
Commit Message:
|
||||
= @pipeline.git_commit_message
|
||||
.p
|
||||
Commit Author:
|
||||
= @pipeline.git_author_name
|
||||
.p
|
||||
Pusher:
|
||||
= @pipeline.user.try(:name)
|
||||
- failed = @pipeline.statuses.latest.failed
|
||||
.p
|
||||
Pipeline #
|
||||
= @pipeline.id
|
||||
had
|
||||
= failed.size
|
||||
failed
|
||||
= 'job'.plural(failed.size)
|
||||
.
|
||||
|
||||
- failed.each do |job|
|
||||
.p
|
||||
ID:
|
||||
= job.id
|
||||
.p
|
||||
Stage:
|
||||
= job.stage
|
||||
.p
|
||||
Name:
|
||||
= job.name
|
||||
.p
|
||||
Trace:
|
||||
= job.trace_with_state[:html].html_safe
|
15
app/views/notify/pipeline_failed_email.text.erb
Normal file
15
app/views/notify/pipeline_failed_email.text.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
Project: <%= @project.path_with_namespace %>
|
||||
Branch: <%= @pipeline.ref %>
|
||||
Commit: <%= @pipeline.short_sha %> (<%= @pipeline.sha %>)
|
||||
Commit Message: <%= @pipeline.git_commit_message %>
|
||||
Commit Author: <%= @pipeline.git_author_name %>
|
||||
Pusher: <%= @pipeline.user.try(:name) %>
|
||||
<% failed = @pipeline.statuses.latest.failed %>
|
||||
Pipeline #<%= @pipeline.id %> had <%= failed.size %> failed <%= 'job'.plural(failed.size) %>.
|
||||
|
||||
<% failed.each do |job| %>
|
||||
ID: <%= job.id %>
|
||||
Stage: <%= job.stage %>
|
||||
Name: <%= job.name %>
|
||||
Trace: <%= job.trace_with_state[:html] %>
|
||||
<% end %>
|
26
app/views/notify/pipeline_succeeded_email.html.haml
Normal file
26
app/views/notify/pipeline_succeeded_email.html.haml
Normal file
|
@ -0,0 +1,26 @@
|
|||
.p
|
||||
Project:
|
||||
= @project.path_with_namespace
|
||||
.p
|
||||
Branch:
|
||||
= @pipeline.ref
|
||||
.p
|
||||
Commit:
|
||||
= @pipeline.short_sha
|
||||
(
|
||||
= @pipeline.sha
|
||||
)
|
||||
.p
|
||||
Commit Message:
|
||||
= @pipeline.git_commit_message
|
||||
.p
|
||||
Commit Author:
|
||||
= @pipeline.git_author_name
|
||||
.p
|
||||
Pusher:
|
||||
= @pipeline.user.try(:name)
|
||||
- failed = @pipeline.statuses.latest.failed
|
||||
.p
|
||||
Pipeline #
|
||||
= @pipeline.id
|
||||
had succeeded.
|
7
app/views/notify/pipeline_succeeded_email.text.erb
Normal file
7
app/views/notify/pipeline_succeeded_email.text.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
Project: <%= @project.path_with_namespace %>
|
||||
Branch: <%= @pipeline.ref %>
|
||||
Commit: <%= @pipeline.short_sha %> (<%= @pipeline.sha %>)
|
||||
Commit Message: <%= @pipeline.git_commit_message %>
|
||||
Commit Author: <%= @pipeline.git_author_name %>
|
||||
Pusher: <%= @pipeline.user.try(:name) %>
|
||||
Pipeline #<%= @pipeline.id %> had succeeded.
|
Loading…
Reference in a new issue