Commit ed986806 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Process skipped jobs in the pipeline when retrying it

parent 1965482f
module Ci module Ci
class RetryPipelineService < ::BaseService class RetryPipelineService < ::BaseService
include Gitlab::OptimisticLocking
def execute(pipeline) def execute(pipeline)
unless can?(current_user, :update_pipeline, pipeline) unless can?(current_user, :update_pipeline, pipeline)
raise Gitlab::Access::AccessDeniedError raise Gitlab::Access::AccessDeniedError
end end
pipeline.builds.failed_or_canceled.tap do |builds| pipeline.builds.failed_or_canceled.find_each do |build|
stage_idx = builds.order('stage_idx ASC') next unless build.retryable?
.pluck('DISTINCT stage_idx').first
pipeline.mark_as_processable_after_stage(stage_idx)
builds.find_each do |build| Ci::RetryBuildService.new(project, current_user)
next unless build.retryable? .reprocess(build)
end
Ci::RetryBuildService.new(project, current_user) pipeline.builds.skipped.find_each do |skipped|
.reprocess(build) retry_optimistic_lock(skipped) { |build| build.process }
end
end end
MergeRequests::AddTodoWhenBuildFailsService MergeRequests::AddTodoWhenBuildFailsService
......
module Gitlab module Gitlab
module OptimisticLocking module OptimisticLocking
extend self module_function
def retry_lock(subject, retries = 100, &block) def retry_lock(subject, retries = 100, &block)
loop do loop do
...@@ -15,5 +15,7 @@ module Gitlab ...@@ -15,5 +15,7 @@ module Gitlab
end end
end end
end end
alias :retry_optimistic_lock :retry_lock
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment