Pipelines for merge requests should show a merge request link in pipeline failure emails
Problem
Sometimes pipeline failure emails for Pipelines for merge requests (or pipelines for merged results, merge train) do not include merge request links (This happens when the pipeline is not the latest pipeline in the MR). For example,
This is hard to identify which branch/MRs got a pipeline failure. Users cannot jump to the context directly.
Proposal
Refactor the Branch
row as Branch refs/merge-requests/:iid/head
doesn't make sense. We should distinguish branch pipelines and pipelines for merge requests.
e.g.
- If the pipeline ran for a branch,
Branch: implement-unleash-client
- If the pipeline ran for a merge request,
Merge request: !17943
(orMerge request: <MR-title-with-link>
)
FYI, the other views (pipeline/job/MRs) have already distinguished these two types of pipelines.
(The top one is a pipeline for merge request, which shows a link to a MR. The bottom one is a branch pipeline, which shows branch name)
We also should change the email subject. For example, GitLab | Pipeline #83130416 has failed for refs/merge-requests/17043/head | 0a2b6006 in !17043
seems cryptic. We should make it more human-readable something like GitLab | Pipeline #83130416 has failed for !17043 | 0a2b6006
Reference:
diff --git a/app/mailers/emails/pipelines.rb b/app/mailers/emails/pipelines.rb
index fb57c0da34d..d7490d7292b 100644
--- a/app/mailers/emails/pipelines.rb
+++ b/app/mailers/emails/pipelines.rb
@@ -15,7 +15,7 @@ module Emails
def pipeline_mail(pipeline, recipients, status)
@project = pipeline.project
@pipeline = pipeline
- @merge_request = pipeline.merge_requests_as_head_pipeline.first
+ @merge_request = pipeline.all_merge_requests.first
add_headers
# We use bcc here because we don't want to generate this emails for a