2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Ci
|
|
|
|
class RetryPipelineService < ::BaseService
|
|
|
|
include Gitlab::OptimisticLocking
|
|
|
|
|
|
|
|
def execute(pipeline)
|
|
|
|
unless can?(current_user, :update_pipeline, pipeline)
|
|
|
|
raise Gitlab::Access::AccessDeniedError
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
needs = Set.new
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline.ensure_scheduling_type!
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
pipeline.retryable_builds.preload_needs.find_each do |build|
|
2017-08-17 22:00:37 +05:30
|
|
|
next unless can?(current_user, :update_build, build)
|
|
|
|
|
|
|
|
Ci::RetryBuildService.new(project, current_user)
|
|
|
|
.reprocess!(build)
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
needs += build.needs.map(&:name)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
pipeline.builds.latest.skipped.find_each do |skipped|
|
|
|
|
retry_optimistic_lock(skipped) { |build| build.process }
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
pipeline.reset_ancestor_bridges!
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
MergeRequests::AddTodoWhenBuildFailsService
|
|
|
|
.new(project, current_user)
|
|
|
|
.close_all(pipeline)
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
Ci::ProcessPipelineService
|
|
|
|
.new(pipeline)
|
2020-10-24 23:57:45 +05:30
|
|
|
.execute
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|