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

web_hook_service.rb « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 87984b20fa16c747bb27fffd0e1b1a8c80ece883 (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
35
36
module Ci
  class WebHookService
    def build_end(build)
      execute_hooks(build.project, build_data(build))
    end

    def execute_hooks(project, data)
      project.web_hooks.each do |web_hook|
        async_execute_hook(web_hook, data)
      end
    end

    def async_execute_hook(hook, data)
      Sidekiq::Client.enqueue(Ci::WebHookWorker, hook.id, data)
    end

    def build_data(build)
      project = build.project
      data = {}
      data.merge!({
        build_id: build.id,
        build_name: build.name,
        build_status: build.status,
        build_started_at: build.started_at,
        build_finished_at: build.finished_at,
        project_id: project.id,
        project_name: project.name,
        gitlab_url: project.gitlab_url,
        ref: build.ref,
        sha: build.sha,
        before_sha: build.before_sha,
        push_data: build.commit.push_data
      })
    end
  end
end