Class: Kuroko2::Workflow::Notifier::Slack
- Inherits:
-
Object
- Object
- Kuroko2::Workflow::Notifier::Slack
- Defined in:
- lib/autoload/kuroko2/workflow/notifier/slack.rb
Defined Under Namespace
Modules: LevelToColor
Instance Attribute Summary collapse
-
#message_builder ⇒ Object
readonly
Returns the value of attribute message_builder.
-
#webhook_url ⇒ Object
readonly
Returns the value of attribute webhook_url.
Instance Method Summary collapse
-
#initialize(instance) ⇒ Slack
constructor
A new instance of Slack.
- #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) ⇒ Slack
Returns a new instance of Slack.
15 16 17 18 19 20 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 15 def initialize(instance) @instance = instance @definition = instance.job_definition @message_builder = Workflow::Notifier::Concerns::ChatMessageBuilder.new(instance) @webhook_url = Kuroko2.config.notifiers.slack.webhook_url end |
Instance Attribute Details
#message_builder ⇒ Object (readonly)
Returns the value of attribute message_builder.
5 6 7 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 5 def @message_builder end |
#webhook_url ⇒ Object (readonly)
Returns the value of attribute webhook_url.
5 6 7 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 5 def webhook_url @webhook_url end |
Instance Method Details
#notify_back_to_normal ⇒ Object
91 92 93 94 95 96 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 91 def notify_back_to_normal ( level: 'SUCCESS', text: .back_to_normal_text, ) end |
#notify_cancellation ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 52 def notify_cancellation if @definition.notify_cancellation || @definition.hipchat_notify_finished? ( level: 'WARNING', text: .failure_text, body: @instance.logs.reverse.detect{ |log| log.level == 'WARN' }.try!(:message), ) end end |
#notify_critical ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 72 def notify_critical ( level: 'CRITICAL', text: .failure_text, body: @instance.logs.last(2).first., ) send_additional_text_to_slack end |
#notify_failure ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 62 def notify_failure ( level: 'FAILURE', text: .failure_text, body: @instance.logs.last(2).first., ) send_additional_text_to_slack end |
#notify_finished ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 82 def notify_finished if @definition.hipchat_notify_finished? ( level: 'SUCCESS', text: .finished_text, ) end end |
#notify_launch ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 22 def notify_launch if @definition.hipchat_notify_finished? ( level: 'INFO', text: .launched_text, body: @instance.logs.reverse.detect{ |log| log.level == 'INFO' }.try!(:message), ) end end |
#notify_long_elapsed_time ⇒ Object
98 99 100 101 102 103 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 98 def notify_long_elapsed_time ( level: 'WARNING', text: .long_elapsed_time_text, ) end |
#notify_retrying ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 32 def if @definition.hipchat_notify_finished? ( level: 'INFO', text: ., body: @instance.logs.last(2).first., ) end end |
#notify_skipping ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 42 def notify_skipping if @definition.hipchat_notify_finished? ( level: 'INFO', text: .skipping_text, body: @instance.logs.last(2).first., ) end end |