Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
87275bd2
Commit
87275bd2
authored
Jan 13, 2022
by
Alishan Ladhani
Committed by
Shinya Maeda
Jan 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent non-retryable jobs from being retried
parent
d679861f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
app/services/ci/play_build_service.rb
app/services/ci/play_build_service.rb
+4
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+5
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+10
-0
spec/services/ci/play_build_service_spec.rb
spec/services/ci/play_build_service_spec.rb
+13
-1
No files found.
app/services/ci/play_build_service.rb
View file @
87275bd2
...
@@ -14,7 +14,10 @@ module Ci
...
@@ -14,7 +14,10 @@ module Ci
AfterRequeueJobService
.
new
(
project
,
current_user
).
execute
(
build
)
AfterRequeueJobService
.
new
(
project
,
current_user
).
execute
(
build
)
end
end
else
else
Ci
::
Build
.
retry
(
build
,
current_user
)
# Retrying in Ci::PlayBuildService is a legacy process that should be removed.
# Instead, callers should explicitly execute Ci::RetryBuildService.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/347493.
build
.
retryable?
?
Ci
::
Build
.
retry
(
build
,
current_user
)
:
build
end
end
end
end
...
...
spec/factories/ci/builds.rb
View file @
87275bd2
...
@@ -597,6 +597,11 @@ FactoryBot.define do
...
@@ -597,6 +597,11 @@ FactoryBot.define do
failure_reason
{
13
}
failure_reason
{
13
}
end
end
trait
:deployment_rejected
do
failed
failure_reason
{
22
}
end
trait
:with_runner_session
do
trait
:with_runner_session
do
after
(
:build
)
do
|
build
|
after
(
:build
)
do
|
build
|
build
.
build_runner_session
(
url:
'https://localhost'
)
build
.
build_runner_session
(
url:
'https://localhost'
)
...
...
spec/models/ci/build_spec.rb
View file @
87275bd2
...
@@ -2002,6 +2002,16 @@ RSpec.describe Ci::Build do
...
@@ -2002,6 +2002,16 @@ RSpec.describe Ci::Build do
it
{
is_expected
.
not_to
be_retryable
}
it
{
is_expected
.
not_to
be_retryable
}
end
end
context
'when build is waiting for deployment approval'
do
subject
{
build_stubbed
(
:ci_build
,
:manual
,
environment:
'production'
)
}
before
do
create
(
:deployment
,
:blocked
,
deployable:
subject
)
end
it
{
is_expected
.
not_to
be_retryable
}
end
end
end
end
end
...
...
spec/services/ci/play_build_service_spec.rb
View file @
87275bd2
...
@@ -122,7 +122,7 @@ RSpec.describe Ci::PlayBuildService, '#execute' do
...
@@ -122,7 +122,7 @@ RSpec.describe Ci::PlayBuildService, '#execute' do
end
end
context
'when build is not a playable manual action'
do
context
'when build is not a playable manual action'
do
let
(
:build
)
{
create
(
:ci_build
,
when: :manual
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
)
}
let!
(
:branch
)
{
create
(
:protected_branch
,
:developers_can_merge
,
name:
build
.
ref
,
project:
project
)
}
let!
(
:branch
)
{
create
(
:protected_branch
,
:developers_can_merge
,
name:
build
.
ref
,
project:
project
)
}
it
'duplicates the build'
do
it
'duplicates the build'
do
...
@@ -138,6 +138,18 @@ RSpec.describe Ci::PlayBuildService, '#execute' do
...
@@ -138,6 +138,18 @@ RSpec.describe Ci::PlayBuildService, '#execute' do
expect
(
build
.
user
).
not_to
eq
user
expect
(
build
.
user
).
not_to
eq
user
expect
(
duplicate
.
user
).
to
eq
user
expect
(
duplicate
.
user
).
to
eq
user
end
end
context
'and is not retryable'
do
let
(
:build
)
{
create
(
:ci_build
,
:deployment_rejected
,
pipeline:
pipeline
)
}
it
'does not duplicate the build'
do
expect
{
service
.
execute
(
build
)
}.
not_to
change
{
Ci
::
Build
.
count
}
end
it
'does not enqueue the build'
do
expect
{
service
.
execute
(
build
)
}.
not_to
change
{
build
.
status
}
end
end
end
end
context
'when build is not action'
do
context
'when build is not action'
do
...
...
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