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:
Grzegorz Bizon 2017-05-05 19:35:32 +02:00
parent e5f24c5490
commit fc121cca5b
2 changed files with 45 additions and 1 deletions

View File

@ -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

View File

@ -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