diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17c7db7d..b59158ba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,6 @@
## lastest(master branch)
+- Drop HipChat notifier
+
## v0.8.0
- Upgrade Rails to v7.0
- Support Ruby 3.2
diff --git a/app/controllers/kuroko2/api/job_definitions_controller.rb b/app/controllers/kuroko2/api/job_definitions_controller.rb
index f6a0c918..133fae01 100644
--- a/app/controllers/kuroko2/api/job_definitions_controller.rb
+++ b/app/controllers/kuroko2/api/job_definitions_controller.rb
@@ -56,7 +56,6 @@ def definition_params(params)
:description,
:script,
:notify_cancellation,
- :hipchat_room,
:hipchat_notify_finished,
:suspended,
:prevent_multi,
diff --git a/app/controllers/kuroko2/job_definitions_controller.rb b/app/controllers/kuroko2/job_definitions_controller.rb
index ff5a0c8d..4ac8b723 100644
--- a/app/controllers/kuroko2/job_definitions_controller.rb
+++ b/app/controllers/kuroko2/job_definitions_controller.rb
@@ -91,7 +91,7 @@ def admin_id_params
end
def definition_params
- params.require(:job_definition).permit(:name, :description, :script, :notify_cancellation, :hipchat_room, :hipchat_notify_finished, :suspended, :prevent_multi, :prevent_multi_on_failure, :hipchat_additional_text, :text_tags, :api_allowed, :slack_channel, :webhook_url)
+ params.require(:job_definition).permit(:name, :description, :script, :notify_cancellation, :hipchat_notify_finished, :suspended, :prevent_multi, :prevent_multi_on_failure, :hipchat_additional_text, :text_tags, :api_allowed, :slack_channel, :webhook_url)
end
def query_params
diff --git a/app/models/kuroko2/job_definition.rb b/app/models/kuroko2/job_definition.rb
index c2079deb..d76fefdf 100644
--- a/app/models/kuroko2/job_definition.rb
+++ b/app/models/kuroko2/job_definition.rb
@@ -1,6 +1,9 @@
class Kuroko2::JobDefinition < Kuroko2::ApplicationRecord
include Kuroko2::TableNameCustomizable
+ # TODO: Drop column in the next release
+ self.ignored_columns += %i[hipchat_room]
+
module PreventMultiStatus
NONE = 0
WORKING_OR_ERROR = 1
diff --git a/app/views/kuroko2/job_definitions/_form.html.slim b/app/views/kuroko2/job_definitions/_form.html.slim
index ce8af4e3..7d8c31c6 100644
--- a/app/views/kuroko2/job_definitions/_form.html.slim
+++ b/app/views/kuroko2/job_definitions/_form.html.slim
@@ -23,9 +23,6 @@
' Allow API execution of this job
label Notification
- .form-group
- label Hipchat Room Name
- = form.text_field :hipchat_room, class: 'form-control', placeholder: 'Hipchat Room name'
.form-group
label Slack Channel
= form.text_field :slack_channel, class: 'form-control', placeholder: '#slack-channel'
@@ -36,7 +33,7 @@
.checkbox
label
= form.check_box :hipchat_notify_finished
- ' Notify all event to Slack/Hipchat/Webhook
+ ' Notify all event to Slack/Webhook
.checkbox
label
diff --git a/app/views/kuroko2/job_definitions/show.html.slim b/app/views/kuroko2/job_definitions/show.html.slim
index 4c6cf775..b96576db 100644
--- a/app/views/kuroko2/job_definitions/show.html.slim
+++ b/app/views/kuroko2/job_definitions/show.html.slim
@@ -43,22 +43,20 @@
h3 Options
h4 Notification
ul
- - if @definition.hipchat_room.present? || @definition.slack_channel.present?
+ - if @definition.slack_channel.present?
- if @definition.hipchat_notify_finished?
li
- 'Notify all event to Slack/Hipchat/Webhook
+ 'Notify all event to Slack/Webhook
ul
li webhook url: #{@definition.webhook_url}
- li hipchat room: #{@definition.hipchat_room}
li slack channel: #{@definition.slack_channel}
- if @definition.hipchat_additional_text
li Failure notification text: #{@definition.hipchat_additional_text}
- else
li
- 'Notify failure event to Slack/Hipchat/Webhook
+ 'Notify failure event to Slack/Webhook
ul
li webhook url: #{@definition.webhook_url}
- li hipchat room: #{@definition.hipchat_room}
li slack channel: #{@definition.slack_channel}
- if @definition.hipchat_additional_text
li Failure notification text: #{@definition.hipchat_additional_text}
@@ -66,7 +64,7 @@
- if @definition.notify_cancellation
li Notify administrators when the job is cancelled by system.
- - if !@definition.hipchat_room.present? && !@definition.slack_channel && !@definition.notify_cancellation
+ - if !@definition.slack_channel && !@definition.notify_cancellation
li None
h4 Next Job Execution
diff --git a/app_template.rb b/app_template.rb
index b74eca90..faff4950 100644
--- a/app_template.rb
+++ b/app_template.rb
@@ -28,11 +28,6 @@
mail_to: "kuroko@example.com"
slack:
webhook_url: 'https://localhost/test/slack'
- hipchat:
- api_token: 'token'
- options:
-# api_version: 'v2'
-# server_url: 'https://api.example.com'
webhook:
secret_token: '<%= ENV["WEBHOOK_SECRET_TOKEN"] %>'
api_basic_authentication_applications:
diff --git a/docs/user_guide.md b/docs/user_guide.md
index 7cddf3b4..463f696b 100644
--- a/docs/user_guide.md
+++ b/docs/user_guide.md
@@ -12,7 +12,7 @@
- Name ... The name of the job.
- Description ... A description of the job.
- Script ... Definition of a workflow, will be explained later.
-- Slack channel / Hipchat room ... A chat room to send a message.
+- Slack channel ... A chat room to send a message.
- Next Job Execution ... Check if you want to prevent multiple instances of same jobs.
![](images/kuroko2_job_form.png)
@@ -92,16 +92,15 @@ Kuroko2 notifies job statuses by below methods.
- Mail
- Slack
-- Hipchat
- Webhook
### Notifications Frequency Options
You can configurable notifications frequency.
-#### Notify all event to Slack/Hipchat/Webhook
+#### Notify all event to Slack/Webhook
-If you enable this option, Kuroko2 notifies all events by Slack/Hipchat/Webhook (except Email) that jobs state is changed,
+If you enable this option, Kuroko2 notifies all events by Slack/Webhook (except Email) that jobs state is changed,
Events is below.
- The job is launched
diff --git a/kuroko2.gemspec b/kuroko2.gemspec
index 4005c569..795088a9 100644
--- a/kuroko2.gemspec
+++ b/kuroko2.gemspec
@@ -45,8 +45,6 @@ Gem::Specification.new do |s|
s.add_dependency 'rinku'
s.add_dependency 'visjs-rails'
- s.add_dependency 'hipchat', '~> 1.3.0'
-
s.add_dependency 'the_garage'
s.add_dependency 'weak_parameters'
diff --git a/lib/autoload/kuroko2/workflow/notifier/hipchat.rb b/lib/autoload/kuroko2/workflow/notifier/hipchat.rb
deleted file mode 100644
index 74f0e9ed..00000000
--- a/lib/autoload/kuroko2/workflow/notifier/hipchat.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-module Kuroko2
- module Workflow
- module Notifier
- class Hipchat
- attr_reader :hipchat, :message_builder
-
- USER_NAME = 'kuroko2'
-
- def initialize(instance)
- hipchat_options = 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, hipchat_options)
- @message_builder = Workflow::Notifier::Concerns::ChatMessageBuilder.new(instance)
- end
-
- def notify_launch
- if @definition.hipchat_notify_finished?
- message = build_message(level: 'SUCCESS', text: message_builder.launched_text)
- message << "
"
- message << @instance.logs.reverse.detect{ |log| log.level == 'INFO' }.try!(:message)
-
- send_to_hipchat(message, color: 'yellow')
- end
- end
-
- def notify_retrying
- if @definition.hipchat_notify_finished
- message = build_message(level: 'SUCCESS', text: message_builder.retrying_text)
- message << "
"
- message << @instance.logs.last(2).first.message
-
- send_to_hipchat(message, color: 'yellow')
- end
- end
-
- def notify_skipping
- if @definition.hipchat_notify_finished
- message = build_message(level: 'SUCCESS', text: message_builder.skipping_text)
- message << "
"
- message << @instance.logs.last(2).first.message
-
- send_to_hipchat(message, color: 'yellow')
- end
- end
-
- def notify_cancellation
- if @definition.notify_cancellation || @definition.hipchat_notify_finished?
- message = build_message(level: 'WARNING', text: message_builder.failure_text)
- message << "
"
- message << @instance.logs.reverse.detect{ |log| log.level == 'WARN' }.try!(:message)
-
- send_to_hipchat(message, color: 'yellow')
- end
- end
-
- def notify_failure
- message = build_message(level: 'FAILURE', text: message_builder.failure_text)
- message << "
"
- message << @instance.logs.last(2).first.message
-
- send_to_hipchat(message, color: 'red', notify: true)
- send_additional_text_to_hipchat
- end
-
- def notify_critical
- message = build_message(level: 'CRITICAL', text: message_builder.failure_text)
- message << "
"
- message << @instance.logs.last(2).first.message
-
- send_to_hipchat(message, color: 'red', notify: true)
- send_additional_text_to_hipchat
- end
-
- def notify_finished
- if @definition.hipchat_notify_finished?
- message = build_message(level: 'SUCCESS', text: message_builder.finished_text)
- send_to_hipchat(message)
- end
- end
-
- def notify_back_to_normal
- message = build_message(level: 'SUCCESS', text: message_builder.back_to_normal_text)
- send_to_hipchat(message)
- end
-
- def notify_long_elapsed_time
- message = build_message(level: 'WARNING', text: message_builder.long_elapsed_time_text)
- send_to_hipchat(message, color: 'red')
- end
-
- private
-
- def send_to_hipchat(message, color: 'green', notify: false, format: 'html')
- if notify_hipchat?
-
- hipchat[@definition.hipchat_room].send(USER_NAME, message, color: color, notify: notify, message_format: format)
- end
- end
-
- def build_message(level: , text:)
- message = "[#{level}] "
- message << text
- message << "(Open)"
- end
-
- def send_additional_text_to_hipchat
- if @definition.hipchat_additional_text.present?
- message = message_builder.additional_text
- send_to_hipchat(message, color: 'red', notify: true, format: 'text')
- end
- end
-
- def notify_hipchat?
- @definition.hipchat_room.present?
- end
- end
- end
- end
-end
diff --git a/lib/kuroko2.rb b/lib/kuroko2.rb
index 0a8dc1fd..fbf74235 100644
--- a/lib/kuroko2.rb
+++ b/lib/kuroko2.rb
@@ -4,7 +4,6 @@
require 'retryable'
require 'faraday'
require 'html/pipeline'
-require 'hipchat'
require 'omniauth-google-oauth2'
require 'omniauth/rails_csrf_protection'
diff --git a/spec/dummy/config/kuroko2.yml b/spec/dummy/config/kuroko2.yml
index 279c5a13..7e921caf 100644
--- a/spec/dummy/config/kuroko2.yml
+++ b/spec/dummy/config/kuroko2.yml
@@ -13,9 +13,6 @@ default: &default
mail_to: "kuroko@example.com"
slack:
webhook_url: 'https://localhost/test/slack'
- hipchat:
- api_token: 'token'
- options:
webhook:
secret_token: 'secret_token'
api_basic_authentication_applications:
diff --git a/spec/requests/api/job_definitions_spec.rb b/spec/requests/api/job_definitions_spec.rb
index 7baeac26..d82d79ae 100644
--- a/spec/requests/api/job_definitions_spec.rb
+++ b/spec/requests/api/job_definitions_spec.rb
@@ -76,7 +76,6 @@
description: "description",
script: "noop:",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
@@ -108,7 +107,6 @@
description: "description",
script: "noop:",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
@@ -232,7 +230,6 @@
description: "description",
script: "noop:",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
@@ -286,7 +283,6 @@
description: "description",
script: "echo: Hello",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
@@ -310,7 +306,6 @@
description: "description",
script: "echo: Hello",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
@@ -340,7 +335,6 @@
description: "description",
script: "noop",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
@@ -364,7 +358,6 @@
description: "description",
script: "echo: Hello",
notify_cancellation: 1,
- hipchat_room: "",
hipchat_notify_finished: 1,
suspended: false,
prevent_multi: 1,
diff --git a/spec/workflow/notifier/hipchat_spec.rb b/spec/workflow/notifier/hipchat_spec.rb
deleted file mode 100644
index db1d4208..00000000
--- a/spec/workflow/notifier/hipchat_spec.rb
+++ /dev/null
@@ -1,240 +0,0 @@
-require 'rails_helper'
-
-module Kuroko2::Workflow
- describe Notifier::Hipchat do
- let(:job_name) { 'My Job' }
- let(:hipchat_room) { 'dummy' }
- let(:instance) do
- create(:job_definition_with_instances, name: job_name, hipchat_room: hipchat_room).
- job_instances.first
- end
-
- let(:notifier) { Notifier::Hipchat.new(instance) }
- let(:hipchat_room_object) { double('Hipchat::Room', send: true) }
-
- before do
- allow(Kuroko2.config.notifiers.hipchat).to receive(:api_token).and_return('token')
-
- instance.logs.info('start!')
- allow(notifier.hipchat).to receive(:[]).with(hipchat_room).
- and_return(hipchat_room_object)
- end
-
- describe '#hipchat' do
- it 'is an instance of HipChat::Client' do
- expect(Notifier::Hipchat.new(instance).hipchat).to be_an_instance_of(::HipChat::Client)
- end
-
- it 'accepts options from conig' do
- options = {
- api_version: 'v2',
- server_url: 'https://api.example.com',
- }
-
- allow(Kuroko2.config.notifiers.hipchat).to receive(:options).
- and_return(Hashie::Mash.new(options))
-
- client = class_double(::HipChat::Client).as_stubbed_const
- expect(client).to receive(:new).with('token', options)
-
- Notifier::Hipchat.new(instance)
- end
- end
-
- describe '#notify_failure' do
- it 'sends failure mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('FAILURE')
- expect(option[:color]).to eq('red')
- end
-
- notifier.notify_failure
- end
-
- context 'with additional_text' do
- let(:additional_text) { '@EisukeOishi' }
- before do
- instance.job_definition.hipchat_additional_text = additional_text
- instance.save!
- end
-
- it 'sends additional message' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('Failed to execute')
- expect(option[:color]).to eq('red')
- end
-
- notifier.notify_failure
- end
- end
- end
-
- describe '#notify_cancellation' do
- before do
- instance.logs.warn('warn')
- instance.job_definition.notify_cancellation = true
- instance.save!
- end
-
- it 'sends cancellation mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('WARNING')
- expect(option[:color]).to eq('yellow')
- end
-
- notifier.notify_cancellation
- end
- end
-
- describe '#notify_critical' do
- it 'sends critical mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('CRITICAL')
- expect(option[:color]).to eq('red')
- end
-
- notifier.notify_critical
- end
-
- context 'with additional_text' do
- let(:additional_text) { '@EisukeOishi' }
- before do
- instance.job_definition.hipchat_additional_text = additional_text
- instance.save!
- end
-
- it 'sends additional message' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('Failed to execute')
- expect(option[:color]).to eq('red')
- end
-
- notifier.notify_failure
- end
- end
- end
-
- describe '#notify_finished' do
- it 'sends finished mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('SUCCESS')
- expect(option[:color]).to eq('green')
- end
-
- notifier.notify_finished
- end
- end
-
- describe '#notify_back_to_normal' do
- it 'sends back_to_normal message' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('SUCCESS')
- expect(option[:color]).to eq('green')
- end
-
- notifier.notify_back_to_normal
- end
- end
-
- describe '#notify_retrying' do
- context 'with notify_finished' do
- before do
- instance.job_definition.hipchat_notify_finished = true
- instance.save!
- end
-
- it 'sends retrying mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('SUCCESS')
- expect(option[:color]).to eq('yellow')
- end
-
- notifier.notify_retrying
- end
- end
-
- context 'without notify_finished' do
- before do
- instance.job_definition.hipchat_notify_finished = false
- instance.save!
- end
-
- it 'sends retrying mesasge' do
- expect(hipchat_room_object).not_to receive(:send)
- notifier.notify_retrying
- end
- end
- end
-
- describe '#notify_skipping' do
- context 'with notify_finished' do
- before do
- instance.job_definition.hipchat_notify_finished = true
- instance.save!
- end
-
- it 'sends skipping mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('SUCCESS')
- expect(option[:color]).to eq('yellow')
- end
-
- notifier.notify_skipping
- end
- end
-
- context 'without notify_finished' do
- before do
- instance.job_definition.hipchat_notify_finished = false
- instance.save!
- end
-
- it 'sends skipping mesasge' do
- expect(hipchat_room_object).not_to receive(:send)
- notifier.notify_skipping
- end
- end
- end
-
- describe '#notify_launch' do
- context 'with notify_finished' do
- before do
- instance.job_definition.hipchat_notify_finished = true
- instance.save!
- end
-
- it 'sends launch mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('SUCCESS')
- expect(option[:color]).to eq('yellow')
- end
-
- notifier.notify_launch
- end
- end
-
- context 'without notify_finished' do
- before do
- instance.job_definition.hipchat_notify_finished = false
- instance.save!
- end
-
- it 'sends launch mesasge' do
- expect(hipchat_room_object).not_to receive(:send)
- notifier.notify_launch
- end
- end
- end
-
- describe '#notify_long_elapsed_time' do
- it 'sends warning mesasge' do
- expect(hipchat_room_object).to receive(:send) do |_, message, option|
- expect(message).to include('WARNING')
- expect(option[:color]).to eq('red')
- end
-
- notifier.notify_long_elapsed_time
- end
- end
- end
-end