1# frozen_string_literal: true 2 3module Ci 4 module Pipelines 5 class HookService 6 include Gitlab::Utils::StrongMemoize 7 8 HOOK_NAME = :pipeline_hooks 9 10 def initialize(pipeline) 11 @pipeline = pipeline 12 end 13 14 def execute 15 project.execute_hooks(hook_data, HOOK_NAME) if project.has_active_hooks?(HOOK_NAME) 16 project.execute_integrations(hook_data, HOOK_NAME) if project.has_active_integrations?(HOOK_NAME) 17 end 18 19 private 20 21 attr_reader :pipeline 22 23 def project 24 @project ||= pipeline.project 25 end 26 27 def hook_data 28 strong_memoize(:hook_data) do 29 Gitlab::DataBuilder::Pipeline.build(pipeline) 30 end 31 end 32 end 33 end 34end 35