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
|
|
|
|
|
2017-04-06 08:31:38 -04:00
|
|
|
pipeline.retryable_builds.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)
|
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|
|
2017-02-23 05:44:49 -05:00
|
|
|
retry_optimistic_lock(skipped) { |build| build.process }
|
2017-02-14 06:20:02 -05:00
|
|
|
end
|
|
|
|
|
2017-02-15 05:02:05 -05:00
|
|
|
MergeRequests::AddTodoWhenBuildFailsService
|
|
|
|
.new(project, current_user)
|
|
|
|
.close_all(pipeline)
|
|
|
|
|
2017-02-14 07:29:58 -05:00
|
|
|
pipeline.process!
|
2017-02-13 10:38:08 -05:00
|
|
|
end
|
2017-02-13 09:14:40 -05:00
|
|
|
end
|
|
|
|
end
|