debian-mirror-gitlab/app/services/ci/pipelines/hook_service.rb

35 lines
724 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module Ci
module Pipelines
class HookService
include Gitlab::Utils::StrongMemoize
HOOK_NAME = :pipeline_hooks
def initialize(pipeline)
@pipeline = pipeline
end
def execute
project.execute_hooks(hook_data, HOOK_NAME) if project.has_active_hooks?(HOOK_NAME)
project.execute_integrations(hook_data, HOOK_NAME) if project.has_active_integrations?(HOOK_NAME)
end
private
attr_reader :pipeline
def project
@project ||= pipeline.project
end
def hook_data
strong_memoize(:hook_data) do
Gitlab::DataBuilder::Pipeline.build(pipeline)
end
end
end
end
end