summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-22 08:39:50 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-22 08:39:50 +0100
commitd16eed3b096bb01efda90dfea47ac549a9d2ffbc (patch)
tree6ee1caeaaf628143f60d86acc11669a84a625ed0
parent5a84b5fd7c5e281de7fad55a308ff35da64f50ca (diff)
downloadgitlab-ce-d16eed3b096bb01efda90dfea47ac549a9d2ffbc.tar.gz
Fix reprocessing skipped jobs when retrying pipeline
-rw-r--r--app/services/ci/retry_pipeline_service.rb2
-rw-r--r--spec/services/ci/retry_pipeline_service_spec.rb25
2 files changed, 25 insertions, 2 deletions
diff --git a/app/services/ci/retry_pipeline_service.rb b/app/services/ci/retry_pipeline_service.rb
index 2c5e130e5aa..7fcbac6399a 100644
--- a/app/services/ci/retry_pipeline_service.rb
+++ b/app/services/ci/retry_pipeline_service.rb
@@ -8,6 +8,8 @@ module Ci
pipeline.builds.failed_or_canceled.find_each do |build|
next unless build.retryable?
+ pipeline.mark_as_processable_after_stage(build.stage_idx)
+
Ci::RetryBuildService.new(project, current_user)
.reprocess(build)
end
diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb
index c0af8b8450a..8b1ed6470e4 100644
--- a/spec/services/ci/retry_pipeline_service_spec.rb
+++ b/spec/services/ci/retry_pipeline_service_spec.rb
@@ -69,6 +69,25 @@ describe Ci::RetryPipelineService, '#execute', :services do
end
end
+ context 'when the last stage was skipepd' do
+ before do
+ create_build('build 1', :success, 0)
+ create_build('test 2', :failed, 1)
+ create_build('report 3', :skipped, 2)
+ create_build('report 4', :skipped, 2)
+ end
+
+ it 'retries builds only in the first stage' 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('report 4')).to be_created
+ expect(pipeline.reload).to be_running
+ end
+ end
+
context 'when pipeline contains manual actions' do
context 'when there is a canceled manual action in first stage' do
before do
@@ -90,14 +109,16 @@ describe Ci::RetryPipelineService, '#execute', :services do
context 'when there is a skipped manual action in last stage' do
before do
create_build('rspec 1', :canceled, 0)
+ create_build('rspec 2', :skipped, 0, :manual)
create_build('staging', :skipped, 1, :manual)
end
- it 'retries canceled job and skips manual action' do
+ it 'retries canceled job and reprocesses manual actions' do
service.execute(pipeline)
expect(build('rspec 1')).to be_pending
- expect(build('staging')).to be_skipped
+ expect(build('rspec 2')).to be_skipped
+ expect(build('staging')).to be_created
expect(pipeline.reload).to be_running
end
end