Installation instruction updated
This commit is contained in:
@@ -22,7 +22,13 @@ Metrics/PerceivedComplexity:
|
||||
|
||||
# Offense count: 15
|
||||
Metrics/AbcSize:
|
||||
Max: 25
|
||||
Max: 65
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Max: 300
|
||||
|
||||
Metrics/ClassLength:
|
||||
Max: 300
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
38
README.md
38
README.md
@@ -1,30 +1,20 @@
|
||||
# Messenger plugin for Redmine
|
||||
|
||||
This plugin posts updates to issues in your Redmine installation to Slack, Rocket.Chat or Mattermost channel.
|
||||
This plugin posts updates to issues in your Redmine installation to (Slack)[https://slack.com/], (Rocket.Chat)[https://rocket.chat/] or (Mattermost)[https://about.mattermost.com/] channel.
|
||||
|
||||
Redmine Supported versions: 3.3.x.
|
||||
|
||||
|
||||
## Screenshot
|
||||
|
||||

|
||||
Redmine Supported versions: 3.0.x.
|
||||
|
||||
## Installation
|
||||
|
||||
From your Redmine plugins directory, clone this repository as `redmine_rocketchat` (note
|
||||
the underscore!):
|
||||
Install ``redmine_messenger`` plugin for `Redmine`_
|
||||
|
||||
git clone https://github.com/phlegx/redmine_rocketchat.git redmine_rocketchat
|
||||
|
||||
You will also need the `httpclient` dependency, which can be installed by running
|
||||
|
||||
bundle install
|
||||
|
||||
from the plugin directory.
|
||||
cd $REDMINE_ROOT
|
||||
git clone git://github.com/alphanodes/redmine_messenger.git plugins/redmine_messenger
|
||||
bundle install --without development test
|
||||
|
||||
Restart Redmine, and you should see the plugin show up in the Plugins page.
|
||||
Under the configuration options, set the Rocket.Chat API URL to the URL for an
|
||||
Incoming WebHook integration in your Rocket.Chat account and also set the Rocket.Chat
|
||||
Under the configuration options, set the Messenger API URL to the URL for an
|
||||
Incoming WebHook integration in your Rocket.Chat account and also set the Messenger
|
||||
Channel to the channel's handle (be careful, this is not the channel's display name
|
||||
visible to users, you can find each channel's handle by navigating inside the channel
|
||||
and clicking the down-arrow and selecting view info). See also the next two sections
|
||||
@@ -34,7 +24,7 @@ for advanced and custom routing options.
|
||||
|
||||
You can also route messages to different channels on a per-project basis. To
|
||||
do this, create a project custom field (Administration > Custom fields > Project)
|
||||
named `Rocket.Chat Channel`. If no custom channel is defined for a project, the parent
|
||||
named `Messenger Channel`. If no custom channel is defined for a project, the parent
|
||||
project will be checked (or the default will be used). To prevent all notifications
|
||||
from being sent for a project, set the custom channel to `-`.
|
||||
|
||||
@@ -42,15 +32,15 @@ For more information, see http://www.redmine.org/projects/redmine/wiki/Plugins (
|
||||
|
||||
## Screenshot Guided Configuration
|
||||
|
||||
Step 1: Create an Incoming Webhook in Rocket.Chat (Administration > Integrations > Incoming WebHook).
|
||||
Step 1: Create an Incoming Webhook in Messenger (Administration > Integrations > Incoming WebHook).
|
||||
|
||||

|
||||
|
||||
Step 2: Install this Redmine plugin for Rocket.Chat.
|
||||
Step 2: Install this Redmine plugin for Messenger.
|
||||
|
||||

|
||||
|
||||
Step 3: Configure this Redmine plugin for Rocket.Chat. For per-project customized routing, leave the `Rocket.Chat Channel` field empty and follow the next steps, otherwise all Redmine projects will post to the same Rocket.Chat channel. Be careful when filling the channel field, you need to input the channel's handle, not the display name visible to users. You can find each channel's handle by going inside the channel and click the down-arrow and selecting view info.
|
||||
Step 3: Configure this Redmine plugin for Messenger. For per-project customized routing, leave the `Messenger Channel` field empty and follow the next steps, otherwise all Redmine projects will post to the same Messenger channel. Be careful when filling the channel field, you need to input the channel's handle, not the display name visible to users. You can find each channel's handle by going inside the channel and click the down-arrow and selecting view info.
|
||||
|
||||

|
||||
|
||||
@@ -59,10 +49,10 @@ Step 4: For per-project customized routing, first create the project custom fiel
|
||||

|
||||

|
||||
|
||||
Step 5: For per-project customized routing, configure the Rocket.Chat channel handle inside your Redmine project.
|
||||
Step 5: For per-project customized routing, configure the Messenger channel handle inside your Redmine project.
|
||||
|
||||

|
||||
|
||||
## Credits
|
||||
|
||||
The source code is forked from https://github.com/altsol/redmine_mattermost. Special thanks to the original author and contributors for making this awesome hook for Redmine. This fork is just refactored to use Rocket.Chat-namespaced configuration options in order to use all hooks (Rocket.Chat, Mattermost and Slack) in a Redmine installation.
|
||||
The source code is forked from https://github.com/altsol/redmine_mattermost. Special thanks to the original author and contributors for making this awesome hook for Redmine. This fork is just refactored to use Messenger-namespaced configuration options in order to use all hooks (Rocket.Chat, Mattermost and Slack) in a Redmine installation.
|
||||
|
||||
@@ -5,18 +5,20 @@ class Messenger
|
||||
include Redmine::I18n
|
||||
|
||||
def self.speak(msg, channels, attachment = nil, url = nil)
|
||||
return if channels.blank?
|
||||
|
||||
url = RedmineMessenger.settings[:messenger_url] unless url
|
||||
username = RedmineMessenger.settings[:messenger_username]
|
||||
icon = RedmineMessenger.settings[:messenger_icon]
|
||||
|
||||
return if url.blank?
|
||||
return if channels.blank?
|
||||
|
||||
params = {
|
||||
text: msg,
|
||||
link_names: 1
|
||||
}
|
||||
|
||||
params[:username] = username if username
|
||||
if RedmineMessenger.settings[:messenger_username].present?
|
||||
params[:username] = RedmineMessenger.settings[:messenger_username]
|
||||
end
|
||||
params[:attachments] = [attachment] if attachment
|
||||
|
||||
if icon.present?
|
||||
@@ -36,7 +38,7 @@ class Messenger
|
||||
client.ssl_config.ssl_version = :auto
|
||||
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
client.post_async url, payload: params.to_json
|
||||
rescue Exception => e
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn("cannot connect to #{url}")
|
||||
Rails.logger.warn(e)
|
||||
end
|
||||
@@ -44,7 +46,7 @@ class Messenger
|
||||
end
|
||||
|
||||
def self.object_url(obj)
|
||||
if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
|
||||
if Setting.host_name.to_s =~ %r{/\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i}
|
||||
host = Regexp.last_match(2)
|
||||
port = Regexp.last_match(4)
|
||||
prefix = Regexp.last_match(5)
|
||||
@@ -89,9 +91,9 @@ class Messenger
|
||||
end
|
||||
|
||||
def self.channels_for_project(proj)
|
||||
return nil if proj.blank?
|
||||
return if proj.blank?
|
||||
|
||||
cf = ProjectCustomField.find_by_name('Messenger Channel')
|
||||
cf = ProjectCustomField.find_by(name: 'Messenger Channel')
|
||||
val = [
|
||||
(proj.custom_value_for(cf).value rescue nil),
|
||||
(channels_for_project proj.parent),
|
||||
|
||||
2
init.rb
2
init.rb
@@ -15,7 +15,7 @@ Redmine::Plugin.register :redmine_messenger do
|
||||
messenger_url: '',
|
||||
messenger_channel: 'redmine',
|
||||
messenger_icon: 'https://raw.githubusercontent.com/alphanodes/redmine_messenger/assets/icon.png',
|
||||
messenger_username: 'redmine.bot',
|
||||
messenger_username: 'robot',
|
||||
display_watchers: '0',
|
||||
auto_mentions: '1',
|
||||
post_updates: '1',
|
||||
|
||||
Reference in New Issue
Block a user