Class: GitlabQuality::TestTooling::Report::GroupIssues::IncidentChecker
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::Report::GroupIssues::IncidentChecker
- Defined in:
- lib/gitlab_quality/test_tooling/report/group_issues/incident_checker.rb
Constant Summary collapse
- GITLAB_PRODUCTION_PROJECT_ID =
gitlab-com/gl-infra/production
'7444821'
Class Method Summary collapse
- .format_incidents_for_issue(incidents) ⇒ Object
- .get_active_incidents(token: nil, gitlab_url: 'https://gitlab.com') ⇒ Object
Class Method Details
.format_incidents_for_issue(incidents) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gitlab_quality/test_tooling/report/group_issues/incident_checker.rb', line 42 def self.format_incidents_for_issue(incidents) return "" if incidents.empty? incident_list = incidents.map { |inc| "- [#{inc[:title]}](#{inc[:url]})" }.join("\n") <<~MARKDOWN ### Related GitLab Incidents The following active incidents may be related to these test failures: #{incident_list} Check the [GitLab Production Issues](https://gitlab.com/gitlab-com/gl-infra/production/-/issues/?label_name%5B%5D=Incident%3A%3AActive) for updates. MARKDOWN end |
.get_active_incidents(token: nil, gitlab_url: 'https://gitlab.com') ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gitlab_quality/test_tooling/report/group_issues/incident_checker.rb', line 12 def self.get_active_incidents(token: nil, gitlab_url: 'https://gitlab.com') return [] unless token begin client = GitlabClient::IssuesClient.new(token: token, endpoint: "#{gitlab_url}/api/v4", project: GITLAB_PRODUCTION_PROJECT_ID) issues = client.find_issues(options: { labels: 'Incident::Active', state: 'opened', per_page: 10, order_by: 'created_at', sort: 'desc' }) issues.map do |issue| { title: issue.title, url: issue.web_url } end rescue Gitlab::Error::Error => e Runtime::Logger.error "GitLab API error fetching incidents: #{e.}" [] rescue StandardError => e Runtime::Logger.error "Warning: Could not fetch active incidents: #{e.}" [] end end |