Class: Ci::CancelUserPipelinesService

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/cancel_user_pipelines_service.rb

Instance Method Summary collapse

Instance Method Details

#execute(user) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord This is a bug with CodeReuse/ActiveRecord cop gitlab.com/gitlab-org/gitlab/issues/32332


8
9
10
11
12
13
14
# File 'app/services/ci/cancel_user_pipelines_service.rb', line 8

def execute(user)
  user.pipelines.cancelable.find_each(&:cancel_running)

  ServiceResponse.success(message: 'Pipeline canceled')
rescue ActiveRecord::StaleObjectError
  ServiceResponse.error(message: 'Error canceling pipeline')
end