class FlowdockBuildNotifier::FlowdockNotification

Attributes

build_id[R]
config[R]

Public Class Methods

new(build_id) click to toggle source
# File lib/flowdock_build_notifier.rb, line 13
def initialize(build_id)
  @build_id = build_id
  @config = Configuration.load
end

Public Instance Methods

author_email() click to toggle source
# File lib/flowdock_build_notifier.rb, line 41
def author_email
  `git show --format=format:%ae`.split("\n").first
end
build() click to toggle source
# File lib/flowdock_build_notifier.rb, line 37
def build
  @build ||= BuildMetadata.new(config: config).tap { |metadata| metadata.fetch(build_id) }
end
message() click to toggle source
# File lib/flowdock_build_notifier.rb, line 33
def message
  NotificationMessage.new(build)
end
notify() click to toggle source
# File lib/flowdock_build_notifier.rb, line 18
def notify
  sender = FlowdockMessageSenderFactory
    .new(config: config)
    .create_sender(notify_email)

  sender.send_message(message)
  notify_all if ENV['FLOWDOCK_NOTIFY_ALL_ON_FAILURE'] && build.status == "FAILURE"
end
notify_all() click to toggle source
# File lib/flowdock_build_notifier.rb, line 27
def notify_all
  TeamRoomSender
    .new(config: config)
    .send_message("#{message} @all")
end
notify_email() click to toggle source
# File lib/flowdock_build_notifier.rb, line 45
def notify_email
  return File.read('.flowdock_notify_email').strip if File.exists? '.flowdock_notify_email'
  author_email
end