Commit ad8ffd50 authored by Furkan Ayhan's avatar Furkan Ayhan

Fix non-restarted skipped bridge jobs

When retrying the whole pipeline, all skipped jobs should be "processed"
, which usually means "transition to created state".

We are doing this for "builds" but not for "bridges". In this commit,
we started to use "processables" to include both.

Changelog: fixed
parent 4fe41b1e
...@@ -17,7 +17,7 @@ module Ci ...@@ -17,7 +17,7 @@ module Ci
Ci::RetryBuildService.new(project, current_user).clone!(build) Ci::RetryBuildService.new(project, current_user).clone!(build)
end end
pipeline.builds.latest.skipped.find_each do |skipped| pipeline.processables.latest.skipped.find_each do |skipped|
retry_optimistic_lock(skipped, name: 'ci_retry_pipeline') { |build| build.process(current_user) } retry_optimistic_lock(skipped, name: 'ci_retry_pipeline') { |build| build.process(current_user) }
end end
......
...@@ -316,6 +316,26 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do ...@@ -316,6 +316,26 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do
expect(bridge.reload).to be_pending expect(bridge.reload).to be_pending
end end
end end
context 'when there are skipped jobs in later stages' do
before do
create_build('build 1', :success, 0)
create_build('test 2', :failed, 1)
create_build('report 3', :skipped, 2)
create_bridge('deploy 4', :skipped, 2)
end
it 'retries failed jobs and processes skipped jobs' do
service.execute(pipeline)
expect(build('build 1')).to be_success
expect(build('test 2')).to be_pending
expect(build('report 3')).to be_created
expect(build('deploy 4')).to be_created
expect(pipeline.reload).to be_running
end
end
end end
context 'when user is not allowed to retry pipeline' do context 'when user is not allowed to retry pipeline' do
...@@ -390,16 +410,25 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do ...@@ -390,16 +410,25 @@ RSpec.describe Ci::RetryPipelineService, '#execute' do
pipeline.reload.statuses pipeline.reload.statuses
end end
# The method name can be confusing because this can actually return both Ci::Build and Ci::Bridge
def build(name) def build(name)
statuses.latest.find_by(name: name) statuses.latest.find_by(name: name)
end end
def create_build(name, status, stage_num, **opts) def create_build(name, status, stage_num, **opts)
create(:ci_build, name: name, create_processable(:ci_build, name, status, stage_num, **opts)
end
def create_bridge(name, status, stage_num, **opts)
create_processable(:ci_bridge, name, status, stage_num, **opts)
end
def create_processable(type, name, status, stage_num, **opts)
create(type, name: name,
status: status, status: status,
stage: "stage_#{stage_num}", stage: "stage_#{stage_num}",
stage_idx: stage_num, stage_idx: stage_num,
pipeline: pipeline, **opts) do |build| pipeline: pipeline, **opts) do |_job|
::Ci::ProcessPipelineService.new(pipeline).execute ::Ci::ProcessPipelineService.new(pipeline).execute
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