Commit 8c59489c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not retry jobs multiple times when retrying a pipeline

parent c848735d
......@@ -7,14 +7,14 @@ module Ci
raise Gitlab::Access::AccessDeniedError
end
pipeline.builds.failed_or_canceled.find_each do |build|
pipeline.builds.latest.failed_or_canceled.find_each do |build|
next unless build.retryable?
Ci::RetryBuildService.new(project, current_user)
.reprocess(build)
end
pipeline.builds.skipped.find_each do |skipped|
pipeline.builds.latest.skipped.find_each do |skipped|
retry_optimistic_lock(skipped) { |build| build.process }
end
......
......@@ -9,6 +9,19 @@ describe Ci::RetryPipelineService, '#execute', :services do
context 'when user has ability to modify pipeline' do
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
before do
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