diff options
Diffstat (limited to 'app/services/ci/cancel_pipeline_service.rb')
-rw-r--r-- | app/services/ci/cancel_pipeline_service.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/services/ci/cancel_pipeline_service.rb b/app/services/ci/cancel_pipeline_service.rb index 52d38520fc3..38053b13921 100644 --- a/app/services/ci/cancel_pipeline_service.rb +++ b/app/services/ci/cancel_pipeline_service.rb @@ -24,11 +24,7 @@ module Ci end def execute - unless can?(current_user, :cancel_pipeline, pipeline) - return ServiceResponse.error( - message: 'Insufficient permissions to cancel the pipeline', - reason: :insufficient_permissions) - end + return permission_error_response unless can?(current_user, :cancel_pipeline, pipeline) force_execute end @@ -103,6 +99,13 @@ module Ci job.cancel end + def permission_error_response + ServiceResponse.error( + message: 'Insufficient permissions to cancel the pipeline', + reason: :insufficient_permissions + ) + end + # For parent child-pipelines only (not multi-project) def cancel_children pipeline.all_child_pipelines.each do |child_pipeline| |