From 8d290d211f418986543aaf2c1c904bbebaf73f65 Mon Sep 17 00:00:00 2001 From: Pete Trump Date: Fri, 30 Jul 2010 10:00:57 -0700 Subject: [PATCH] Add "project.email_notifier.always_notify" attribute to specify whether or not to send build notifications for every build on a project-specific basis. --- config/cruise_config.rb.example | 5 ++++- lib/builder_plugins/email_notifier.rb | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config/cruise_config.rb.example b/config/cruise_config.rb.example index e4e64ec..ff11be4 100644 --- a/config/cruise_config.rb.example +++ b/config/cruise_config.rb.example @@ -8,6 +8,9 @@ Project.configure do |project| # Set email 'from' field to john@doe.com: # project.email_notifier.from = 'john@doe.com' + # Always send email notification upon build completion: + # project.email_notifier.always_notify = true + # Build the project by invoking rake task 'custom' # project.rake_task = 'custom' @@ -25,4 +28,4 @@ Project.configure do |project| # Force the project to check for source control changes every given time interval, but NOT build if there are no changes # project.triggered_by ScheduledBuildTrigger.new(project, :build_interval => 5.minutes, :start_time => 2.minutes.from_now) -end \ No newline at end of file +end diff --git a/lib/builder_plugins/email_notifier.rb b/lib/builder_plugins/email_notifier.rb index 170fa36..a424211 100644 --- a/lib/builder_plugins/email_notifier.rb +++ b/lib/builder_plugins/email_notifier.rb @@ -24,7 +24,7 @@ # #
Configuration.dashboard_url = 'http://your.host.name.com:3333'
class EmailNotifier < BuilderPlugin - attr_accessor :emails + attr_accessor :emails, :always_notify attr_writer :from def initialize(project = nil) @@ -36,15 +36,22 @@ class EmailNotifier < BuilderPlugin end def build_finished(build) - return if @emails.empty? or not build.failed? - email :deliver_build_report, build, "#{build.project.name} build #{build.abbreviated_label} failed", + return if @emails.empty? + if build.failed? then + email :deliver_build_report, build, "#{build.project.name} build #{build.abbreviated_label} failed", "The build failed." + elsif @always_notify == true then + email :deliver_build_report, build, "#{build.project.name} build #{build.abbreviated_label} finished", + "The build has finished." + end end def build_fixed(build, previous_build) return if @emails.empty? - email :deliver_build_report, build, "#{build.project.name} build #{build.abbreviated_label} fixed", + if not @always_notify == true then + email :deliver_build_report, build, "#{build.project.name} build #{build.abbreviated_label} fixed", "The build has been fixed." + end end private @@ -60,4 +67,4 @@ class EmailNotifier < BuilderPlugin end -Project.plugin :email_notifier \ No newline at end of file +Project.plugin :email_notifier -- 1.6.3.3