Class: Ci::RetryPipelineService

Inherits:
BaseService show all
Includes:
Gitlab::OptimisticLocking
Defined in:
app/services/ci/retry_pipeline_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::OptimisticLocking

retry_lock

Methods inherited from BaseService

#initialize

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?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(pipeline) ⇒ Object


7
8
9
10
11
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
# File 'app/services/ci/retry_pipeline_service.rb', line 7

def execute(pipeline)
  unless can?(current_user, :update_pipeline, pipeline)
    raise Gitlab::Access::AccessDeniedError
  end

  needs = Set.new

  pipeline.ensure_scheduling_type!

  pipeline.retryable_builds.preload_needs.find_each do |build|
    next unless can?(current_user, :update_build, build)

    Ci::RetryBuildService.new(project, current_user)
      .reprocess!(build)

    needs += build.needs.map(&:name)
  end

  pipeline.builds.latest.skipped.find_each do |skipped|
    retry_optimistic_lock(skipped) { |build| build.process }
  end

  MergeRequests::AddTodoWhenBuildFailsService
    .new(project, current_user)
    .close_all(pipeline)

  Ci::ProcessPipelineService
    .new(pipeline)
    .execute
end