Do not reprocess actions when user retries pipeline
User who is not allowed to trigger manual actions should not be allowed to reprocess / retrigger / retry these actions.
This commit is contained in:
parent
e5f24c5490
commit
fc121cca5b
|
@ -8,6 +8,8 @@ module Ci
|
|||
end
|
||||
|
||||
pipeline.retryable_builds.find_each do |build|
|
||||
next unless can?(current_user, :update_build, build)
|
||||
|
||||
Ci::RetryBuildService.new(project, current_user)
|
||||
.reprocess(build)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,9 @@ describe Ci::RetryPipelineService, '#execute', :services do
|
|||
let(:service) { described_class.new(project, user) }
|
||||
|
||||
context 'when user has ability to modify pipeline' do
|
||||
let(:user) { create(:admin) }
|
||||
before do
|
||||
project.add_master(user)
|
||||
end
|
||||
|
||||
context 'when there are already retried jobs present' do
|
||||
before do
|
||||
|
@ -227,6 +229,46 @@ describe Ci::RetryPipelineService, '#execute', :services do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when user is not allowed to trigger manual action' do
|
||||
before do
|
||||
project.add_developer(user)
|
||||
end
|
||||
|
||||
context 'when there is a failed manual action present' do
|
||||
before do
|
||||
create_build('test', :failed, 0)
|
||||
create_build('deploy', :failed, 0, when: :manual)
|
||||
create_build('verify', :canceled, 1)
|
||||
end
|
||||
|
||||
it 'does not reprocess manual action' do
|
||||
service.execute(pipeline)
|
||||
|
||||
expect(build('test')).to be_pending
|
||||
expect(build('deploy')).to be_failed
|
||||
expect(build('verify')).to be_created
|
||||
expect(pipeline.reload).to be_running
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is a failed manual action in later stage' do
|
||||
before do
|
||||
create_build('test', :failed, 0)
|
||||
create_build('deploy', :failed, 1, when: :manual)
|
||||
create_build('verify', :canceled, 2)
|
||||
end
|
||||
|
||||
it 'does not reprocess manual action' do
|
||||
service.execute(pipeline)
|
||||
|
||||
expect(build('test')).to be_pending
|
||||
expect(build('deploy')).to be_failed
|
||||
expect(build('verify')).to be_created
|
||||
expect(pipeline.reload).to be_running
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def statuses
|
||||
pipeline.reload.statuses
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue