Commit 856d2991 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'fix/gb/pipeline-retry-only-latest-jobs' into 'master'

Do not retry jobs multiple times when retrying a pipeline

Closes #30092

See merge request !10249
parents a5647149 414de2cf
...@@ -7,14 +7,14 @@ module Ci ...@@ -7,14 +7,14 @@ module Ci
raise Gitlab::Access::AccessDeniedError raise Gitlab::Access::AccessDeniedError
end end
pipeline.builds.failed_or_canceled.find_each do |build| pipeline.builds.latest.failed_or_canceled.find_each do |build|
next unless build.retryable? next unless build.retryable?
Ci::RetryBuildService.new(project, current_user) Ci::RetryBuildService.new(project, current_user)
.reprocess(build) .reprocess(build)
end end
pipeline.builds.skipped.find_each do |skipped| pipeline.builds.latest.skipped.find_each do |skipped|
retry_optimistic_lock(skipped) { |build| build.process } retry_optimistic_lock(skipped) { |build| build.process }
end end
......
---
title: Fix bug that caused jobs that already had been retried to be retried again
when retrying a pipeline
merge_request: 10249
author:
...@@ -9,6 +9,19 @@ describe Ci::RetryPipelineService, '#execute', :services do ...@@ -9,6 +9,19 @@ describe Ci::RetryPipelineService, '#execute', :services do
context 'when user has ability to modify pipeline' do context 'when user has ability to modify pipeline' do
let(:user) { create(:admin) } let(:user) { create(:admin) }
context 'when there are already retried jobs present' do
before do
create_build('rspec', :canceled, 0)
create_build('rspec', :failed, 0)
end
it 'does not retry jobs that has already been retried' do
expect(statuses.first).to be_retried
expect { service.execute(pipeline) }
.to change { CommitStatus.count }.by(1)
end
end
context 'when there are failed builds in the last stage' do context 'when there are failed builds in the last stage' do
before do before do
create_build('rspec 1', :success, 0) create_build('rspec 1', :success, 0)
......
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