2017-02-13 14:14:40 +00:00
|
|
|
module Ci
|
2017-02-14 09:38:17 +00:00
|
|
|
class RetryPipelineService < ::BaseService
|
2017-02-23 10:44:49 +00:00
|
|
|
include Gitlab::OptimisticLocking
|
|
|
|
|
2017-02-14 09:38:17 +00:00
|
|
|
def execute(pipeline)
|
|
|
|
unless can?(current_user, :update_pipeline, pipeline)
|
2017-02-13 14:14:40 +00:00
|
|
|
raise Gitlab::Access::AccessDeniedError
|
|
|
|
end
|
|
|
|
|
2017-04-06 12:31:38 +00:00
|
|
|
pipeline.retryable_builds.find_each do |build|
|
2017-05-05 17:35:32 +00:00
|
|
|
next unless can?(current_user, :update_build, build)
|
|
|
|
|
2017-02-23 10:44:49 +00:00
|
|
|
Ci::RetryBuildService.new(project, current_user)
|
|
|
|
.reprocess(build)
|
|
|
|
end
|
2017-02-22 08:06:58 +00:00
|
|
|
|
2017-03-27 07:11:29 +00:00
|
|
|
pipeline.builds.latest.skipped.find_each do |skipped|
|
2017-02-23 10:44:49 +00:00
|
|
|
retry_optimistic_lock(skipped) { |build| build.process }
|
2017-02-14 11:20:02 +00:00
|
|
|
end
|
|
|
|
|
2017-02-15 10:02:05 +00:00
|
|
|
MergeRequests::AddTodoWhenBuildFailsService
|
|
|
|
.new(project, current_user)
|
|
|
|
.close_all(pipeline)
|
|
|
|
|
2017-02-14 12:29:58 +00:00
|
|
|
pipeline.process!
|
2017-02-13 15:38:08 +00:00
|
|
|
end
|
2017-02-13 14:14:40 +00:00
|
|
|
end
|
|
|
|
end
|