Class: MergeRequests::AddTodoWhenBuildFailsService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/add_todo_when_build_fails_service.rb

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods inherited from BaseService

#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_external_hooks, #execute_hooks, #handle_assignees_change, #handle_changes, #handle_reviewers_change, #hook_data, #inspect, #merge_request_activity_counter, #source_project, #target_project

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from AssignsMergeParams

#assign_allowed_merge_params, included

Methods inherited from BaseProjectService

#initialize

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Instance Method Details

#close(commit_status) ⇒ Object

Closes any pending build failed todos for the parent MRs when a build is retried


18
19
20
# File 'app/services/merge_requests/add_todo_when_build_fails_service.rb', line 18

def close(commit_status)
  close_all(commit_status.pipeline)
end

#close_all(pipeline) ⇒ Object


22
23
24
25
26
# File 'app/services/merge_requests/add_todo_when_build_fails_service.rb', line 22

def close_all(pipeline)
  pipeline_merge_requests(pipeline) do |merge_request|
    todo_service.merge_request_build_retried(merge_request)
  end
end

#execute(commit_status) ⇒ Object

Adds a todo to the parent merge_request when a CI build fails


7
8
9
10
11
12
13
# File 'app/services/merge_requests/add_todo_when_build_fails_service.rb', line 7

def execute(commit_status)
  return if commit_status.allow_failure? || commit_status.retried?

  pipeline_merge_requests(commit_status.pipeline) do |merge_request|
    todo_service.merge_request_build_failed(merge_request)
  end
end