2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-13 09:14:40 -05:00
|
|
|
module Ci
|
2017-02-14 04:38:17 -05:00
|
|
|
class RetryPipelineService < ::BaseService
|
2017-02-23 05:44:49 -05:00
|
|
|
include Gitlab::OptimisticLocking
|
|
|
|
|
2017-02-14 04:38:17 -05:00
|
|
|
def execute(pipeline)
|
|
|
|
unless can?(current_user, :update_pipeline, pipeline)
|
2017-02-13 09:14:40 -05:00
|
|
|
raise Gitlab::Access::AccessDeniedError
|
|
|
|
end
|
|
|
|
|
2019-12-06 13:07:44 -05:00
|
|
|
needs = Set.new
|
|
|
|
|
2020-05-15 11:08:04 -04:00
|
|
|
pipeline.ensure_scheduling_type!
|
|
|
|
|
2019-12-06 13:07:44 -05:00
|
|
|
pipeline.retryable_builds.preload_needs.find_each do |build|
|
2017-05-05 13:35:32 -04:00
|
|
|
next unless can?(current_user, :update_build, build)
|
|
|
|
|
2017-02-23 05:44:49 -05:00
|
|
|
Ci::RetryBuildService.new(project, current_user)
|
2017-04-16 07:14:39 -04:00
|
|
|
.reprocess!(build)
|
2019-12-06 13:07:44 -05:00
|
|
|
|
|
|
|
needs += build.needs.map(&:name)
|
2017-02-23 05:44:49 -05:00
|
|
|
end
|
2017-02-22 03:06:58 -05:00
|
|
|
|
2017-03-27 03:11:29 -04:00
|
|
|
pipeline.builds.latest.skipped.find_each do |skipped|
|
2021-03-02 10:10:57 -05:00
|
|
|
retry_optimistic_lock(skipped, name: 'ci_retry_pipeline') { |build| build.process(current_user) }
|
2017-02-14 06:20:02 -05:00
|
|
|
end
|
|
|
|
|
2021-04-30 14:10:09 -04:00
|
|
|
pipeline.reset_source_bridge!(current_user)
|
2020-09-17 08:09:37 -04:00
|
|
|
|
2021-04-01 17:09:22 -04:00
|
|
|
::MergeRequests::AddTodoWhenBuildFailsService
|
2017-02-15 05:02:05 -05:00
|
|
|
.new(project, current_user)
|
|
|
|
.close_all(pipeline)
|
|
|
|
|
2019-11-19 07:06:00 -05:00
|
|
|
Ci::ProcessPipelineService
|
|
|
|
.new(pipeline)
|
2020-08-13 11:10:03 -04:00
|
|
|
.execute
|
2017-02-13 10:38:08 -05:00
|
|
|
end
|
2017-02-13 09:14:40 -05:00
|
|
|
end
|
|
|
|
end
|