BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
6a398883
Commit
6a398883
authored
Feb 23, 2017
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/gb/pipeline-retry-skipped-jobs' into 'master'
Fix reprocessing skipped jobs when retrying pipeline See merge request !9436
parents
70997dea
ca378aa3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
4 deletions
+46
-4
retry_pipeline_service.rb
app/services/ci/retry_pipeline_service.rb
+6
-0
optimistic_locking.rb
lib/gitlab/optimistic_locking.rb
+3
-1
optimistic_locking_spec.rb
spec/lib/gitlab/optimistic_locking_spec.rb
+14
-1
retry_pipeline_service_spec.rb
spec/services/ci/retry_pipeline_service_spec.rb
+23
-2
No files found.
app/services/ci/retry_pipeline_service.rb
View file @
6a398883
module
Ci
class
RetryPipelineService
<
::
BaseService
include
Gitlab
::
OptimisticLocking
def
execute
(
pipeline
)
unless
can?
(
current_user
,
:update_pipeline
,
pipeline
)
raise
Gitlab
::
Access
::
AccessDeniedError
...
...
@@ -12,6 +14,10 @@ module Ci
.
reprocess
(
build
)
end
pipeline
.
builds
.
skipped
.
find_each
do
|
skipped
|
retry_optimistic_lock
(
skipped
)
{
|
build
|
build
.
process
}
end
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
project
,
current_user
)
.
close_all
(
pipeline
)
...
...
lib/gitlab/optimistic_locking.rb
View file @
6a398883
module
Gitlab
module
OptimisticLocking
extend
self
module_function
def
retry_lock
(
subject
,
retries
=
100
,
&
block
)
loop
do
...
...
@@ -15,5 +15,7 @@ module Gitlab
end
end
end
alias_method
:retry_optimistic_lock
,
:retry_lock
end
end
spec/lib/gitlab/optimistic_locking_spec.rb
View file @
6a398883
require
'spec_helper'
describe
Gitlab
::
OptimisticLocking
,
lib:
true
do
describe
'#retry_lock'
do
let!
(
:pipeline
)
{
create
(
:ci_pipeline
)
}
let!
(
:pipeline2
)
{
Ci
::
Pipeline
.
find
(
pipeline
.
id
)
}
describe
'#retry_lock'
do
it
'does not reload object if state changes'
do
expect
(
pipeline
).
not_to
receive
(
:reload
)
expect
(
pipeline
).
to
receive
(
:succeed
).
and_call_original
...
...
@@ -36,4 +36,17 @@ describe Gitlab::OptimisticLocking, lib: true do
end
.
to
raise_error
(
ActiveRecord
::
StaleObjectError
)
end
end
describe
'#retry_optimistic_lock'
do
context
'when locking module is mixed in'
do
let
(
:unlockable
)
do
Class
.
new
.
include
(
described_class
).
new
end
it
'is an alias for retry_lock'
do
expect
(
unlockable
.
method
(
:retry_optimistic_lock
))
.
to
eq
unlockable
.
method
(
:retry_lock
)
end
end
end
end
spec/services/ci/retry_pipeline_service_spec.rb
View file @
6a398883
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment