Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Rehfeld
committed
Sep 17, 2008
0 parents
commit 79240f3
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cruisecontrol.rb-plugins | ||
======================== | ||
|
||
A place for my cruisecontrol.rb plugin(s): So far the short list consists of: | ||
* EmailReporter (will mail a build report after every build -- as opposed to standard EmailNotifier, which will only report state changes (build broken/fixed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Put this file into your CRUISE_DATA_ROOT/builder_plugins directory to enable | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# CruiseControl.rb can send email reports on every build. To make it happen, you need to tell it how | ||
# to send email, and who to send it to. Do the following: | ||
# | ||
# 1. Configure SMTP server connection. Open <em>[cruise data]</em>/config/site_config.rb, | ||
# read the comments in it and edit according to your situation. | ||
# | ||
# 2. Tell the builder, whom do you want to receive build notices: | ||
# <pre><code>Project.configure do |project| | ||
# ... | ||
# project.email_reporter.emails = ['john@doe.com', 'jane@doe.com'] | ||
# ... | ||
# end</code></pre> | ||
# | ||
# You can also specify who to send the email from, either for the entire site by setting Configuration.email_from | ||
# in <em>[cruise data]</em>/config/site_config.rb, or on a per project basis, by placing the following line in cruise_config.rb: | ||
# <pre><code>Project.configure do |project| | ||
# ... | ||
# project.email_reporter.from = "cruisecontrol@doe.com" | ||
# ... | ||
# end</code></pre> | ||
# | ||
# The emails from CruiseControl.rb can have a lot of details about the build, or just a link to the build page in the dashboard. | ||
# Usually, you will want the latter. Set the dashboard URL in the <em>[cruise data]</em>/config/site_config.rb as follows: | ||
# | ||
# <pre><code>Configuration.dashboard_url = 'http://your.host.name.com:3333'</pre></code> | ||
|
||
class EmailReporter | ||
attr_accessor :emails | ||
attr_writer :from | ||
|
||
def initialize(project = nil) | ||
@emails = [] | ||
end | ||
|
||
def from | ||
@from || Configuration.email_from | ||
end | ||
|
||
def build_finished(build) | ||
return if @emails.empty? | ||
email :deliver_build_report, build, "#{build.project.name} build #{build.label} #{build.failed? ? 'failed' : 'succeded'}", "The build #{build.failed? ? 'failed' : 'succeded'}." | ||
end | ||
|
||
private | ||
|
||
def email(template, build, *args) | ||
BuildMailer.send(template, build, @emails, from, *args) | ||
CruiseControl::Log.event("Sent e-mail to #{@emails.size == 1 ? "1 person" : "#{@emails.size} people"}", :debug) | ||
rescue => e | ||
settings = ActionMailer::Base.smtp_settings.map { |k,v| " #{k.inspect} = #{v.inspect}" }.join("\n") | ||
CruiseControl::Log.event("Error sending e-mail - current server settings are :\n#{settings}", :error) | ||
raise | ||
end | ||
|
||
end | ||
|
||
Project.plugin :email_reporter | ||
|