Class: Ci::WebHookService

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/web_hook_service.rb

Instance Method Summary collapse

Instance Method Details

#async_execute_hook(hook, data) ⇒ Object


13
14
15
# File 'app/services/ci/web_hook_service.rb', line 13

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

#build_data(build) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/services/ci/web_hook_service.rb', line 17

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,
    before_sha: build.before_sha,
    sha: build.sha,
  })
end

#build_end(build) ⇒ Object


3
4
5
# File 'app/services/ci/web_hook_service.rb', line 3

def build_end(build)
  execute_hooks(build.project, build_data(build))
end

#execute_hooks(project, data) ⇒ Object


7
8
9
10
11
# File 'app/services/ci/web_hook_service.rb', line 7

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