Class: Kuroko2::Workflow::Notifier::Hipchat
- Inherits:
-
Object
- Object
- Kuroko2::Workflow::Notifier::Hipchat
- Defined in:
- lib/autoload/kuroko2/workflow/notifier/hipchat.rb
Constant Summary collapse
- USER_NAME =
'kuroko2'
Instance Attribute Summary collapse
-
#hipchat ⇒ Object
readonly
Returns the value of attribute hipchat.
-
#message_builder ⇒ Object
readonly
Returns the value of attribute message_builder.
Instance Method Summary collapse
-
#initialize(instance) ⇒ Hipchat
constructor
A new instance of Hipchat.
- #notify_back_to_normal ⇒ Object
- #notify_cancellation ⇒ Object
- #notify_critical ⇒ Object
- #notify_failure ⇒ Object
- #notify_finished ⇒ Object
- #notify_launch ⇒ Object
- #notify_long_elapsed_time ⇒ Object
- #notify_retrying ⇒ Object
- #notify_skipping ⇒ Object
Constructor Details
#initialize(instance) ⇒ Hipchat
Returns a new instance of Hipchat.
9 10 11 12 13 14 15 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 9 def initialize(instance) = Kuroko2.config.notifiers.hipchat.try!(:options).try!(:symbolize_keys) || {} @instance = instance @definition = instance.job_definition @hipchat = HipChat::Client.new(Kuroko2.config.notifiers.hipchat.api_token, ) = Workflow::Notifier::Concerns::ChatMessageBuilder.new(instance) end |
Instance Attribute Details
#hipchat ⇒ Object (readonly)
Returns the value of attribute hipchat.
5 6 7 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 5 def hipchat @hipchat end |
#message_builder ⇒ Object (readonly)
Returns the value of attribute message_builder.
5 6 7 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 5 def end |
Instance Method Details
#notify_back_to_normal ⇒ Object
82 83 84 85 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 82 def notify_back_to_normal = (level: 'SUCCESS', text: .back_to_normal_text) send_to_hipchat() end |
#notify_cancellation ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 47 def notify_cancellation if @definition.notify_cancellation || @definition.hipchat_notify_finished? = (level: 'WARNING', text: .failure_text) << "<br>" << @instance.logs.reverse.detect{ |log| log.level == 'WARN' }.try!(:message) send_to_hipchat(, color: 'yellow') end end |
#notify_critical ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 66 def notify_critical = (level: 'CRITICAL', text: .failure_text) << "<br>" << @instance.logs.last(2).first. send_to_hipchat(, color: 'red', notify: true) send_additional_text_to_hipchat end |
#notify_failure ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 57 def notify_failure = (level: 'FAILURE', text: .failure_text) << "<br>" << @instance.logs.last(2).first. send_to_hipchat(, color: 'red', notify: true) send_additional_text_to_hipchat end |
#notify_finished ⇒ Object
75 76 77 78 79 80 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 75 def notify_finished if @definition.hipchat_notify_finished? = (level: 'SUCCESS', text: .finished_text) send_to_hipchat() end end |
#notify_launch ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 17 def notify_launch if @definition.hipchat_notify_finished? = (level: 'SUCCESS', text: .launched_text) << "<br>" << @instance.logs.reverse.detect{ |log| log.level == 'INFO' }.try!(:message) send_to_hipchat(, color: 'yellow') end end |
#notify_long_elapsed_time ⇒ Object
87 88 89 90 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 87 def notify_long_elapsed_time = (level: 'WARNING', text: .long_elapsed_time_text) send_to_hipchat(, color: 'red') end |
#notify_retrying ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 27 def if @definition.hipchat_notify_finished = (level: 'SUCCESS', text: .) << "<br>" << @instance.logs.last(2).first. send_to_hipchat(, color: 'yellow') end end |
#notify_skipping ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/autoload/kuroko2/workflow/notifier/hipchat.rb', line 37 def notify_skipping if @definition.hipchat_notify_finished = (level: 'SUCCESS', text: .skipping_text) << "<br>" << @instance.logs.last(2).first. send_to_hipchat(, color: 'yellow') end end |