Installation instruction updated

This commit is contained in:
Alexander Meindl
2017-05-10 12:08:38 +02:00
parent 69a4070dcb
commit d8010c6ff0
4 changed files with 32 additions and 34 deletions

View File

@@ -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

View File

@@ -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
![screenshot](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/screenshot.png)
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).
![step1](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/step1.png)
Step 2: Install this Redmine plugin for Rocket.Chat.
Step 2: Install this Redmine plugin for Messenger.
![step2](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/step2.png)
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.
![step3](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/step3.png)
@@ -59,10 +49,10 @@ Step 4: For per-project customized routing, first create the project custom fiel
![step4a](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/step4a.png)
![step4b](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/step4b.png)
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.
![step5](https://raw.githubusercontent.com/phlegx/redmine_rocketchat/assets/step5.png)
## 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.

View File

@@ -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),

View File

@@ -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',