debian-mirror-gitlab/app/services/ci/retry_pipeline_service.rb

41 lines
1 KiB
Ruby
Raw Normal View History

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|
2021-04-17 20:07:23 +05:30
retry_optimistic_lock(skipped, name: 'ci_retry_pipeline') { |build| build.process(current_user) }
2017-08-17 22:00:37 +05:30
end
2020-11-24 15:15:51 +05:30
pipeline.reset_ancestor_bridges!
2021-04-29 21:17:54 +05:30
::MergeRequests::AddTodoWhenBuildFailsService
2017-08-17 22:00:37 +05:30
.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