Changeset 50

Show
Ignore:
Timestamp:
01/18/08 16:05:27 (7 months ago)
Author:
muness
Message:

merged with main branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • incubator/cc_campfire_notifier/campfire_notifier.rb

    r18 r50  
    2828   
    2929  def build_finished(build) 
     30    clear_flag 
    3031    build_text = "Build #{build.label}" 
    3132    speak(build.failed? ? "#{build_text} broken" : "#{build_text} successful") 
     
    3334 
    3435  def build_fixed(build, previous_build=nil) 
     36    clear_flag 
    3537    speak("Build fixed in #{build.label}") 
     38  end 
     39   
     40  def build_loop_failed(error) 
     41    return if flagged? && is_subversion_down?(error) 
     42    if is_subversion_down?(error) 
     43      speak "Build loop failed: Error connecting to Subversion" 
     44      set_flag 
     45    else 
     46      speak( "Build loop failed with: #{error.class}: #{error.message}") 
     47      error.backtrace.each { |line| speak line } rescue nil 
     48    end 
    3649  end 
    3750 
     
    4659    CruiseControl::Log 
    4760  end 
     61   
     62  def flagged? 
     63    File.exists?("#{@project.name}.svn_flag") 
     64  end 
     65     
     66  def set_flag 
     67    File.open("#{@project.name}.svn_flag","w") do |file| 
     68      file.puts "#{@project.name} subversion down" 
     69    end 
     70  end 
     71   
     72  def clear_flag 
     73    return unless flagged? 
     74    File.delete("#{@project.name}.svn_flag") 
     75    speak "Subversion is back" 
     76  end 
     77     
     78  def is_subversion_down?(error) 
     79    /svn: PROPFIND request failed/.match(error.message) 
     80  end 
    4881 
    4982end 
  • incubator/cc_campfire_notifier/README.txt

    r30 r50  
    22 
    33h2. Description 
    4 A plugin for CruiseControl.rb to Send notifications to a Campfire room with the build status (success, failure, fixed).  Supports different rooms per build 
     4A plugin for CruiseControl.rb that does the following features: 
     5 * Send notifications to a Campfire room with the build status (success, failure, fixed).   
     6 * Detects and sends notifications re Subversion failures.   
     7 * Supports different rooms per build. 
    58 
    69h2. Install 
     
    1619 
    1720h2. URLS 
     21* "Home page":http://rubyforge.org/projects/campfire-ccrb/ 
    1822* "svn trunk":https://opensource.thinkrelevance.com/svn/incubator/cc_campfire_notifier/campfire_notifier.rb 
    1923* "CC.rb plugins documentation":http://cruisecontrolrb.thoughtworks.com/documentation/plugins 
    20 * "original campfire notifier":http://rubyforge.org/projects/campfire-ccrb/ 
    2124 
    2225h2. LICENSE 
    2326 
    24 (The MIT License) 
    25  
    26 Copyright (c) 2007-08 Relevance 
     27Copyright (c) 2007-8 Giles Bowkett with Contributions from Muness Alrubaie 
    2728 
    2829Permission is hereby granted, free of charge, to any person obtaining 
  • incubator/cc_campfire_notifier/test/campfire_notifier_test.rb

    r18 r50  
    66 
    77describe "CampfireNotifier" do 
    8  it "speaks when the build is fixed" do 
    9    notifier = CampfireNotifier.new 
    10    build = stub(:label => "label") 
    11    notifier.expects(:speak).with("Build fixed in label") 
    12    notifier.build_fixed(build) 
    13  end 
    14  it "speaks when the build is successful" do 
    15    notifier = CampfireNotifier.new 
    16    build = stub(:label => "label", :failed? => false) 
    17    notifier.expects(:speak).with("Build label successful") 
    18    notifier.build_finished(build) 
    19  end 
    20  it "speaks when the build fails" do 
    21    notifier = CampfireNotifier.new 
    22    build = stub(:label => "label", :failed? => true) 
    23    notifier.expects(:speak).with("Build label broken") 
    24    notifier.build_finished(build) 
    25  end 
    26  it "room is nil if no room_name is set" do 
    27    notifer = CampfireNotifier.new 
    28    notifer.room.should == nil 
    29  end 
    30  it "delegates settings to the class variable settings" do 
    31    CampfireNotifier.stubs(:settings).returns(settings = stub) 
    32    CampfireNotifier.new.settings.should == settings 
    33  end 
     8  it "speaks when the build is fixed" do 
     9    notifier = CampfireNotifier.new 
     10    build = stub(:label => "label") 
     11    notifier.expects(:speak).with("Build fixed in label") 
     12    notifier.expects(:clear_flag) 
     13    notifier.build_fixed(build) 
     14  end 
     15  it "speaks when the build is successful" do 
     16    notifier = CampfireNotifier.new 
     17    build = stub(:label => "label", :failed? => false) 
     18    notifier.expects(:speak).with("Build label successful") 
     19    notifier.expects(:clear_flag) 
     20    notifier.build_finished(build) 
     21  end 
     22  it "speaks when the build fails" do 
     23    notifier = CampfireNotifier.new 
     24    build = stub(:label => "label", :failed? => true) 
     25    notifier.expects(:speak).with("Build label broken") 
     26    notifier.expects(:clear_flag) 
     27    notifier.build_finished(build) 
     28  end 
     29  it "speaks when the build loop fails because of a subversion error" do 
     30    notifier = CampfireNotifier.new 
     31    notifier.stubs(:flagged?).returns(false) 
     32    notifier.expects(:speak).with("Build loop failed: Error connecting to Subversion") 
     33    notifier.expects(:is_subversion_down?).returns(true) 
     34    notifier.expects(:set_flag) 
     35    notifier.build_loop_failed(stub) 
     36  end 
     37  it "room is nil if room_name is nil" do 
     38    notifer = CampfireNotifier.new 
     39    notifer.room_name = nil 
     40    notifer.room.should == nil 
     41  end 
     42  it "delegates settings to the class variable settings" do 
     43    CampfireNotifier.stubs(:settings).returns(settings = stub) 
     44    CampfireNotifier.new.settings.should == settings 
     45  end 
    3446end