gitlab-org--gitlab-foss/app/services/ci/destroy_pipeline_service.rb
Stan Hu 2d233dac45 Clear pipeline status cache after destruction of pipeline
`project.pipeline_status.has_status?` is cached, which can lead to Error
500s in the UI if the this condition is used to check whether a pipeline
exists for a commit. We now expire the cache to ensure that the
information is consistent.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59453
2019-03-26 01:04:06 -05:00

13 lines
344 B
Ruby

# frozen_string_literal: true
module Ci
class DestroyPipelineService < BaseService
def execute(pipeline)
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :destroy_pipeline, pipeline)
pipeline.destroy!
Gitlab::Cache::Ci::ProjectPipelineStatus.new(pipeline.project).delete_from_cache
end
end
end