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_cancellation ⇒ Object
- #notify_critical ⇒ Object
- #notify_failure ⇒ Object
- #notify_finished ⇒ Object
- #notify_long_elapsed_time ⇒ Object
- #notify_working ⇒ Object
Constructor Details
#initialize(instance) ⇒ Slack
Returns a new instance of Slack.
14 15 16 17 18 19 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 14 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_cancellation ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 25 def notify_cancellation if @definition.notify_cancellation ( level: 'WARNING', text: .failure_text, body: @instance.logs.last(2).first., ) end end |
#notify_critical ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 45 def notify_critical ( level: 'CRITICAL', text: .failure_text, body: @instance.logs.last(2).first., ) send_additional_text_to_slack end |
#notify_failure ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 35 def notify_failure ( level: 'FAILURE', text: .failure_text, body: @instance.logs.last(2).first., ) send_additional_text_to_slack end |
#notify_finished ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 55 def notify_finished if @definition.hipchat_notify_finished? ( level: 'SUCCESS', text: .finished_text, ) end end |
#notify_long_elapsed_time ⇒ Object
64 65 66 67 68 69 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 64 def notify_long_elapsed_time ( level: 'WARNING', text: .long_elapsed_time_text, ) end |
#notify_working ⇒ Object
21 22 23 |
# File 'lib/autoload/kuroko2/workflow/notifier/slack.rb', line 21 def notify_working # do nothing end |