Changeset 50
- Timestamp:
- 01/18/08 16:05:27 (7 months ago)
- Files:
-
- incubator/cc_campfire_notifier/campfire_notifier.rb (modified) (3 diffs)
- incubator/cc_campfire_notifier/README.txt (modified) (2 diffs)
- incubator/cc_campfire_notifier/test/campfire_notifier_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
incubator/cc_campfire_notifier/campfire_notifier.rb
r18 r50 28 28 29 29 def build_finished(build) 30 clear_flag 30 31 build_text = "Build #{build.label}" 31 32 speak(build.failed? ? "#{build_text} broken" : "#{build_text} successful") … … 33 34 34 35 def build_fixed(build, previous_build=nil) 36 clear_flag 35 37 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 36 49 end 37 50 … … 46 59 CruiseControl::Log 47 60 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 48 81 49 82 end incubator/cc_campfire_notifier/README.txt
r30 r50 2 2 3 3 h2. 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 4 A 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. 5 8 6 9 h2. Install … … 16 19 17 20 h2. URLS 21 * "Home page":http://rubyforge.org/projects/campfire-ccrb/ 18 22 * "svn trunk":https://opensource.thinkrelevance.com/svn/incubator/cc_campfire_notifier/campfire_notifier.rb 19 23 * "CC.rb plugins documentation":http://cruisecontrolrb.thoughtworks.com/documentation/plugins 20 * "original campfire notifier":http://rubyforge.org/projects/campfire-ccrb/21 24 22 25 h2. LICENSE 23 26 24 (The MIT License) 25 26 Copyright (c) 2007-08 Relevance 27 Copyright (c) 2007-8 Giles Bowkett with Contributions from Muness Alrubaie 27 28 28 29 Permission is hereby granted, free of charge, to any person obtaining incubator/cc_campfire_notifier/test/campfire_notifier_test.rb
r18 r50 6 6 7 7 describe "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 34 46 end
