Add mock email templates
This commit is contained in:
parent
0997cfd750
commit
1bd2327c31
|
@ -11,28 +11,27 @@ module Emails
|
||||||
private
|
private
|
||||||
|
|
||||||
def pipeline_mail(params, to, status)
|
def pipeline_mail(params, to, status)
|
||||||
@params = params
|
@project = params.project
|
||||||
|
@pipeline = params.pipeline
|
||||||
add_headers
|
add_headers
|
||||||
|
|
||||||
mail(to: to, subject: pipeline_subject(status))
|
mail(to: to, subject: pipeline_subject(status))
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_headers
|
def add_headers
|
||||||
@project = @params.project # `add_project_headers` needs this
|
|
||||||
add_project_headers
|
add_project_headers
|
||||||
add_pipeline_headers(@params.pipeline)
|
add_pipeline_headers
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_pipeline_headers(pipeline)
|
def add_pipeline_headers
|
||||||
headers['X-GitLab-Pipeline-Id'] = pipeline.id
|
headers['X-GitLab-Pipeline-Id'] = @pipeline.id
|
||||||
headers['X-GitLab-Pipeline-Ref'] = pipeline.ref
|
headers['X-GitLab-Pipeline-Ref'] = @pipeline.ref
|
||||||
headers['X-GitLab-Pipeline-Status'] = pipeline.status
|
headers['X-GitLab-Pipeline-Status'] = @pipeline.status
|
||||||
end
|
end
|
||||||
|
|
||||||
def pipeline_subject(status)
|
def pipeline_subject(status)
|
||||||
subject(
|
subject(
|
||||||
"Pipeline #{status} for #{@params.project.name}",
|
"Pipeline #{status} for #{@project.name}", @pipeline.short_sha)
|
||||||
@params.pipeline.short_sha)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,8 +133,11 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def trace_with_state(state = nil)
|
def trace_with_state(state = nil)
|
||||||
trace_with_state = Ci::Ansi2html::convert(trace, state) if trace.present?
|
if trace.present?
|
||||||
trace_with_state || {}
|
Ci::Ansi2html.convert(trace, state)
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def timeout
|
def timeout
|
||||||
|
|
|
@ -198,6 +198,7 @@ class Service < ActiveRecord::Base
|
||||||
bamboo
|
bamboo
|
||||||
buildkite
|
buildkite
|
||||||
builds_email
|
builds_email
|
||||||
|
pipelines_email
|
||||||
bugzilla
|
bugzilla
|
||||||
campfire
|
campfire
|
||||||
custom_issue_tracker
|
custom_issue_tracker
|
||||||
|
|
|
@ -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
|
|
@ -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 %>
|
|
@ -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.
|
|
@ -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 New Issue