Welcome to mirror list, hosted at ThFree Co, Russian Federation.

hook_service.rb « pipelines « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 629ed7e1ebd085c899bc5e5d5c1c3cf49ac10460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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