diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 670a7ca36f48f586faef7d14f34ed15b4901d5c7..f9c3d3f270fc73c7505c2411b91d5833da312958 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -94,6 +94,38 @@ module GitlabRoutingHelper namespace_project_merge_request_url(entity.project.namespace, entity.project, entity, *args) end + def pipeline_url(pipeline, *args) + namespace_project_pipeline_url( + pipeline.project.namespace, + pipeline.project, + pipeline.id, + *args) + end + + def pipeline_build_url(pipeline, build, *args) + namespace_project_build_url( + pipeline.project.namespace, + pipeline.project, + build.id, + *args) + end + + def commits_url(entity, *args) + namespace_project_commits_url( + entity.project.namespace, + entity.project, + entity.ref, + *args) + end + + def commit_url(entity, *args) + namespace_project_commit_url( + entity.project.namespace, + entity.project, + entity.sha, + *args) + end + def project_snippet_url(entity, *args) namespace_project_snippet_url(entity.project.namespace, entity.project, entity, *args) end diff --git a/app/views/notify/pipeline_failed_email.html.haml b/app/views/notify/pipeline_failed_email.html.haml index 1f7b354f4bc954c343c8444b1bb785070daa7636..ec02c2e2d9051899a1cc1265e67d1e3a57c4faf0 100644 --- a/app/views/notify/pipeline_failed_email.html.haml +++ b/app/views/notify/pipeline_failed_email.html.haml @@ -92,7 +92,7 @@ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"} %img{height: "13", src: image_url('mailers/ci_pipeline_notif_v1/icon-branch-gray.gif'), style: "display:block;", width: "13"}/ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"} - %a.muted{href: namespace_project_commits_url(@project.namespace, @project, @pipeline.ref), style: "color:#333333;text-decoration:none;"} + %a.muted{href: commits_url(@pipeline), style: "color:#333333;text-decoration:none;"} = @pipeline.ref %tr %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;color:#8c8c8c;font-weight:300;padding:14px 0;margin:0;border-top:1px solid #ededed;"} Commit @@ -103,7 +103,7 @@ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"} %img{height: "13", src: image_url('mailers/ci_pipeline_notif_v1/icon-commit-gray.gif'), style: "display:block;", width: "13"}/ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"} - %a{href: namespace_project_commit_url(@project.namespace, @project, @pipeline.sha), style: "color:#3084bb;text-decoration:none;"} + %a{href: commit_url(@pipeline), style: "color:#3084bb;text-decoration:none;"} = @pipeline.short_sha - if @merge_request in @@ -134,7 +134,7 @@ %tr.pre-section %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#333333;font-size:15px;font-weight:400;line-height:1.4;padding:15px 0;"} Pipeline - %a{href: namespace_project_pipeline_url(@project.namespace, @project, @pipeline.id), style: "color:#3084bb;text-decoration:none;"} + %a{href: pipeline_url(@pipeline), style: "color:#3084bb;text-decoration:none;"} = "\##{@pipeline.id}" had = failed.size @@ -158,7 +158,7 @@ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#8c8c8c;font-weight:500;font-size:15px;vertical-align:middle;"} = build.stage %td{align: "right", style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding:20px 0;color:#8c8c8c;font-weight:500;font-size:15px;"} - %a{href: namespace_project_build_url(@project.namespace, @project, build.id), style: "color:#3084bb;text-decoration:none;"} + %a{href: pipeline_build_url(@pipeline, build), style: "color:#3084bb;text-decoration:none;"} = build.name %tr.build-log %td{colspan: "2", style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding:0 0 15px;"} diff --git a/app/views/notify/pipeline_failed_email.text.erb b/app/views/notify/pipeline_failed_email.text.erb index 1b249c0cb7c3e3f0dcecffb42d226c5f499fc17c..8f8084b58e1ce3cb56248fe462206a48ff195537 100644 --- a/app/views/notify/pipeline_failed_email.text.erb +++ b/app/views/notify/pipeline_failed_email.text.erb @@ -1,12 +1,12 @@ Your pipeline has failed. Project: <%= @project.name %> ( <%= project_url(@project) %> ) -Branch: <%= @pipeline.ref %> ( <%= namespace_project_commits_url(@project.namespace, @project, @pipeline.ref) %> ) +Branch: <%= @pipeline.ref %> ( <%= commits_url(@pipeline) %> ) <% if @merge_request -%> Merge Request: <%= @merge_request.to_reference %> ( <%= merge_request_url(@merge_request) %> ) <% end -%> -Commit: <%= @pipeline.short_sha %> ( <%= namespace_project_commit_url(@project.namespace, @project, @pipeline.sha) %> ) +Commit: <%= @pipeline.short_sha %> ( <%= commit_url(@pipeline) %> ) Commit Message: <%= @pipeline.git_commit_message.truncate(50) %> <% commit = @pipeline.commit -%> <% if commit.author -%> @@ -16,10 +16,10 @@ Commit Author: <%= commit.author_name %> <% end -%> <% failed = @pipeline.statuses.latest.failed -%> -Pipeline #<%= @pipeline.id %> ( <%= namespace_project_pipeline_url(@project.namespace, @project, @pipeline.id) %> ) had <%= failed.size %> failed <%= 'build'.pluralize(failed.size) %>. +Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) had <%= failed.size %> failed <%= 'build'.pluralize(failed.size) %>. <% failed.each do |build| -%> -Build #<%= build.id %> ( <%= namespace_project_build_url(@project.namespace, @project, build.id) %> ) +Build #<%= build.id %> ( <%= pipeline_build_url(@pipeline, build) %> ) Stage: <%= build.stage %> Name: <%= build.name %> Trace: <%= build.trace_with_state(last_lines: 10)[:text] %> diff --git a/app/views/notify/pipeline_success_email.html.haml b/app/views/notify/pipeline_success_email.html.haml index 81b32524fb2df07be9869440382758e39eadeb89..0fdf118c9bcf86bbcd48c5fe7fd6bc293a2872a6 100644 --- a/app/views/notify/pipeline_success_email.html.haml +++ b/app/views/notify/pipeline_success_email.html.haml @@ -92,7 +92,7 @@ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"} %img{height: "13", src: image_url('mailers/ci_pipeline_notif_v1/icon-branch-gray.gif'), style: "display:block;", width: "13"}/ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"} - %a.muted{href: namespace_project_commits_url(@project.namespace, @project, @pipeline.ref), style: "color:#333333;text-decoration:none;"} + %a.muted{href: commits_url(@pipeline), style: "color:#333333;text-decoration:none;"} = @pipeline.ref %tr %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;color:#8c8c8c;font-weight:300;padding:14px 0;margin:0;border-top:1px solid #ededed;"} Commit @@ -103,7 +103,7 @@ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"} %img{height: "13", src: image_url('mailers/ci_pipeline_notif_v1/icon-commit-gray.gif'), style: "display:block;", width: "13"}/ %td{style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"} - %a{href: namespace_project_commit_url(@project.namespace, @project, @pipeline.sha), style: "color:#3084bb;text-decoration:none;"} + %a{href: commit_url(@pipeline), style: "color:#3084bb;text-decoration:none;"} = @pipeline.short_sha - if @merge_request in @@ -135,7 +135,7 @@ - build_count = @pipeline.statuses.latest.size - stage_count = @pipeline.stages.size Pipeline - %a{href: namespace_project_pipeline_url(@project.namespace, @project, @pipeline.id), style: "color:#3084bb;text-decoration:none;"} + %a{href: pipeline_url(@pipeline), style: "color:#3084bb;text-decoration:none;"} = "\##{@pipeline.id}" successfully completed = "#{build_count} #{'build'.pluralize(build_count)}" diff --git a/app/views/notify/pipeline_success_email.text.erb b/app/views/notify/pipeline_success_email.text.erb index 7e7eec6d09cd8831739dd8b132a2a17d87ff8608..afca0a1b8082492d32a1504f3e03cf1d038d02bb 100644 --- a/app/views/notify/pipeline_success_email.text.erb +++ b/app/views/notify/pipeline_success_email.text.erb @@ -1,12 +1,12 @@ Your pipeline has passed. Project: <%= @project.name %> ( <%= project_url(@project) %> ) -Branch: <%= @pipeline.ref %> ( <%= namespace_project_commits_url(@project.namespace, @project, @pipeline.ref) %> ) +Branch: <%= @pipeline.ref %> ( <%= commits_url(@pipeline.ref) %> ) <% if @merge_request -%> Merge Request: <%= @merge_request.to_reference %> ( <%= merge_request_url(@merge_request) %> ) <% end -%> -Commit: <%= @pipeline.short_sha %> ( <%= namespace_project_commit_url(@project.namespace, @project, @pipeline.sha) %> ) +Commit: <%= @pipeline.short_sha %> ( <%= commit_url(@pipeline) %> ) Commit Message: <%= @pipeline.git_commit_message.truncate(50) %> <% commit = @pipeline.commit -%> <% if commit.author -%> @@ -17,7 +17,7 @@ Commit Author: <%= commit.author_name %> <% build_count = @pipeline.statuses.latest.size -%> <% stage_count = @pipeline.stages.size -%> -Pipeline #<%= @pipeline.id %> ( <%= namespace_project_pipeline_url(@project.namespace, @project, @pipeline.id) %> ) successfully completed <%= build_count %> <%= 'build'.pluralize(build_count) %> in <%= stage_count %> <%= 'stage'.pluralize(stage_count) %>. +Pipeline #<%= @pipeline.id %> ( <%= pipeline_url(@pipeline) %> ) successfully completed <%= build_count %> <%= 'build'.pluralize(build_count) %> in <%= stage_count %> <%= 'stage'.pluralize(stage_count) %>. You're receiving this email because of your account on <%= Gitlab.config.gitlab.host %>. Manage all notifications: <%= profile_notifications_url %>