Skip to content
Snippets Groups Projects
Unverified Commit f2215a2b authored by Stan Hu's avatar Stan Hu
Browse files

Prevent retried builds from being retried again

Previously if a build were retried, we would still allow it to be
retried again. While this is convenient for running a build again, it
also means that a build can be retried again even if there is another
build running.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/331361

Changelog: changed
parent bfe2457a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -469,7 +469,13 @@ def cancelable?
end
 
def retryable?
!archived? && (success? || failed? || canceled?)
if Feature.enabled?(:prevent_retry_of_retried_jobs, project, default_enabled: :yaml)
return false if retried? || archived?
success? || failed? || canceled?
else
!archived? && (success? || failed? || canceled?)
end
end
 
def retries_count
Loading
Loading
---
name: prevent_retry_of_retried_jobs
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62349
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/331695
milestone: '14.0'
type: development
group: group::continuous integration
default_enabled: false
Loading
Loading
@@ -1880,6 +1880,26 @@
 
it { is_expected.not_to be_retryable }
end
context 'when a canceled build has been retried already' do
before do
project.add_developer(user)
build.cancel!
described_class.retry(build, user)
end
context 'when prevent_retry_of_retried_jobs feature flag is enabled' do
it { is_expected.not_to be_retryable }
end
context 'when prevent_retry_of_retried_jobs feature flag is disabled' do
before do
stub_feature_flags(prevent_retry_of_retried_jobs: false)
end
it { is_expected.to be_retryable }
end
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment