Skip to content
Snippets Groups Projects
Commit fc121cca authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

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.
parent e5f24c54
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
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