Commit 1bd2327c authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Add mock email templates

parent 06954c8673c8
......@@ -11,28 +11,27 @@ def pipeline_failed_email(params, to)
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 @@ def trace_html
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 @@ def self.available_services_names
bamboo
buildkite
builds_email
pipelines_email
bugzilla
campfire
custom_issue_tracker
......
.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
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 %>
.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.
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.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment