forked from yeah/redmine_hoptoad_server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 89c9cb0
Showing
7 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
= hoptoad_server | ||
|
||
This is a simple Redmine plugin that makes Redmine act like a Hoptoad server. All exceptions caught and sent by HoptoadNotifier will create or update an Issue in Redmine. | ||
|
||
= Installation & Configuration | ||
|
||
Just install the Plugin following the general Redmine plugin installation instructions at http://www.redmine.org/wiki/redmine/Plugins. | ||
|
||
Then, go to Administration -> Settings -> Incoming emails in your Redmine and generate an API key. | ||
|
||
Now, download and install the HoptoadNotifier following the excellent instructions on their github page http://github.com/thoughtbot/hoptoad_notifier. | ||
|
||
When it comes to creating your config/initializers/hoptoad.rb file, deviate from the standard and put in something like this: | ||
|
||
HoptoadNotifier.configure do |config| | ||
config.api_key = {:project => 'my_redmine_project_identifier', # the one you specified for your project in Redmine | ||
:tracker => 'Bug', # the name of your Tracker of choice in Redmine | ||
:api_key => 'my_redmine_api_key', # the key you generated before in Redmine (NOT YOUR HOPTOAD API KEY!) | ||
:category => 'Development', # the name of a ticket category (optional.) | ||
:assigned_to => 'admin', # the login of a user the ticket should get assigned to by default (optional.) | ||
:priority => 5 # the default priority (use a number, not a name. optional.) | ||
}.to_yaml | ||
config.host = 'my_redmine_host.com' # the hostname your Redmine runs at | ||
config.port = 443 # the port your Redmine runs at | ||
end | ||
|
||
You're done. You can start receiving your Exceptions in Redmine! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class NoticesController < ApplicationController | ||
unloadable | ||
def index | ||
notice = YAML.load(request.raw_post)['notice'] | ||
redmine_params = YAML.load(notice['api_key']) | ||
|
||
if authorized = Setting.mail_handler_api_key == redmine_params[:api_key] | ||
|
||
project = Project.find_by_name(redmine_params[:project]) | ||
tracker = project.trackers.find_by_name(redmine_params[:tracker]) | ||
author = User.anonymous | ||
|
||
issue = Issue.find_or_initialize_by_subject_and_project_id_and_tracker_id_and_author_id_and_description(notice['error_message'], | ||
project.id, | ||
tracker.id, | ||
author.id, | ||
'Hoptoad Issue') | ||
|
||
if issue.new_record? | ||
issue.category = IssueCategory.find_by_name(redmine_params[:category]) unless redmine_params[:category].blank? | ||
issue.assigned_to = User.find_by_login(redmine_params[:assigned_to]) unless redmine_params[:assigned_to].blank? | ||
issue.priority_id = redmine_params[:priority] unless redmine_params[:priority].blank? | ||
end | ||
|
||
issue.save! | ||
|
||
journal = issue.init_journal(author, "h4. Backtrace\n\n<pre>#{notice['back'].to_yaml}</pre>\n\n | ||
h4. Request\n\n<pre>#{notice['request'].to_yaml}</pre>\n\n | ||
h4. Session\n\n<pre>#{notice['session'].to_yaml}</pre>\n\n | ||
h4. Environment\n\n<pre>#{notice['environment'].to_yaml}</pre>") | ||
|
||
if issue.status.blank? or issue.status.is_closed? | ||
issue.status = IssueStatus.find(:first, :conditions => {:is_default => true}, :order => 'position ASC') | ||
end | ||
|
||
|
||
issue.save! | ||
|
||
if issue.new_record? | ||
Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added') | ||
else | ||
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') | ||
end | ||
|
||
render :status => 200, :text => "Received bug report. Created/updated issue #{issue.id}." | ||
else | ||
logger.info 'Unauthorized Hoptoad API request.' | ||
render :status => 403, :text => 'You provided a wrong or no Redmine API key.' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module NoticesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'redmine' | ||
|
||
Redmine::Plugin.register :redmine_hoptoad_server do | ||
name 'Redmine Hoptoad Server plugin' | ||
author 'Jan Schulz-Hofen' | ||
description 'This plugin turns Redmin into a Hoptoad server, i.e. an API provider which can be used with the hoptoad_notifier which is available at: http://www.hoptoadapp.com/' | ||
version '0.0.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# English strings go here | ||
my_label: "My label" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class NoticesControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Load the normal Rails helper | ||
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') | ||
|
||
# Ensure that we are using the temporary fixture path | ||
Engines::Testing.set_fixture_path |