From 748738ea9dd86ee5d90d7d7c499a67bf8bcb479e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Fri, 14 Oct 2022 15:33:28 +0100
Subject: [PATCH] ci: Include bridge jobs in failed pipeline notification
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Rémy Coutable <remy@rymai.me>
---
 .gitlab/ci/rules.gitlab-ci.yml      | 1 +
 scripts/api/pipeline_failed_jobs.rb | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml
index 9fbb089d9732c..afe900f39a692 100644
--- a/.gitlab/ci/rules.gitlab-ci.yml
+++ b/.gitlab/ci/rules.gitlab-ci.yml
@@ -1001,6 +1001,7 @@
     - <<: *if-merge-request-targeting-stable-branch
       allow_failure: true
     - <<: *if-ruby3-branch
+      allow_failure: true
     - <<: *if-dot-com-gitlab-org-and-security-merge-request-manual-ff-package-and-e2e
       changes: *feature-flag-development-config-patterns
       when: manual
diff --git a/scripts/api/pipeline_failed_jobs.rb b/scripts/api/pipeline_failed_jobs.rb
index 3c29e8842d3ea..c25567af69844 100644
--- a/scripts/api/pipeline_failed_jobs.rb
+++ b/scripts/api/pipeline_failed_jobs.rb
@@ -31,6 +31,13 @@ def execute
       failed_jobs << job
     end
 
+    client.pipeline_bridges(project, pipeline_id, scope: 'failed', per_page: 100).auto_paginate do |job|
+      next if exclude_allowed_to_fail_jobs && job.allow_failure
+
+      job.web_url = job.downstream_pipeline.web_url # job.web_url is linking to an invalid page
+      failed_jobs << job
+    end
+
     failed_jobs
   end
 
-- 
GitLab