-
Notifications
You must be signed in to change notification settings - Fork 0
/
ampel_notifier.rb
40 lines (30 loc) · 1.06 KB
/
ampel_notifier.rb
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
37
38
39
40
require 'net/http'
class AmpelNotifier
def initialize(project)
@activated = false
end
def remote_server(options = {})
@host = options[:host]
@port = options[:port]
end
def activate!
@activated = true
end
def activated?
@activated
end
def build_started(build)
Net::HTTP.get(@host, "/ampel_server/change_state?ci[project_name]=#{build.project.name}&ci[build_state]=building", @port) if activated?
end
def build_finished(build)
status = build.failed? ? "broken" : "good"
Net::HTTP.get(@host, "/ampel_server/change_state?ci[project_name]=#{build.project.name}&ci[build_state]=#{status}", @port) if activated?
end
def build_fixed(build, previous_build)
Net::HTTP.get(@host, "/ampel_server/change_state?ci[project_name]=#{build.project.name}&ci[build_state]=good", @port) if activated?
end
def build_broken(build, previous_build)
Net::HTTP.get(@host, "/ampel_server/change_state?ci[project_name]=#{build.project.name}&ci[build_state]=broken", @port) if activated?
end
end
Project.plugin :ampel_notifier