2018-11-12 13:18:57 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
|
|
|
class DestroyPipelineService < BaseService
|
|
|
|
def execute(pipeline)
|
2018-11-13 11:27:00 -05:00
|
|
|
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :destroy_pipeline, pipeline)
|
2018-11-12 13:18:57 -05:00
|
|
|
|
2019-04-12 15:29:47 -04:00
|
|
|
Ci::ExpirePipelineCacheService.new.execute(pipeline, delete: true)
|
2019-03-26 02:01:14 -04:00
|
|
|
|
2019-04-12 15:29:47 -04:00
|
|
|
pipeline.destroy!
|
2020-08-27 11:10:21 -04:00
|
|
|
|
|
|
|
ServiceResponse.success(message: 'Pipeline not found')
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
ServiceResponse.error(message: 'Pipeline not found')
|
2018-11-12 13:18:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|