Twitter notifier for CruiseControl.rb


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. gem "twitter4r", ">=0.3.0"
  2. require "twitter"
  3. require "time"
  4.  
  5. class TwitterNotifier
  6.  
  7. attr_writer :login, :password
  8.  
  9. def initialize(project)
  10. @project = project
  11.  
  12. Twitter::Client.configure do |conf|
  13. conf.user_agent = 'cruisecontrolrb'
  14. conf.application_name = 'CruiseControl.rb'
  15. conf.application_version = 'v1.2.1'
  16. conf.application_url = 'http://cruisecontrolrb.thoughtworks.com/'
  17. end
  18.  
  19. def build_finished(build)
  20. return unless @login and build.failed?
  21. Twitter::Client.new(:login => @login, :password => @password).
  22. status(:post, "#{build.project.name} build #{build.label} failed") rescue nil
  23. end
  24.  
  25. def build_fixed(build, previous_build)
  26. return unless @login
  27. Twitter::Client.new(:login => @login, :password => @password).
  28. status(:post, "#{build.project.name} build #{build.label} fixed") rescue nil
  29. end
  30.  
  31. end
  32.  
  33. end
  34.  
  35. Project.plugin :twitter_notifier

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.