diff --git a/app/assets/images/gitlab_create.png b/app/assets/images/gitlab_create.png new file mode 100644 index 0000000..9c4f8b5 Binary files /dev/null and b/app/assets/images/gitlab_create.png differ diff --git a/app/assets/images/gitlab_goto.png b/app/assets/images/gitlab_goto.png new file mode 100644 index 0000000..9c4f8b5 Binary files /dev/null and b/app/assets/images/gitlab_goto.png differ diff --git a/app/assets/images/gitlab_inactive.png b/app/assets/images/gitlab_inactive.png new file mode 100644 index 0000000..0917fd2 Binary files /dev/null and b/app/assets/images/gitlab_inactive.png differ diff --git a/app/models/issue_trackers/gitlab_tracker.rb b/app/models/issue_trackers/gitlab_tracker.rb new file mode 100644 index 0000000..3c469a0 --- /dev/null +++ b/app/models/issue_trackers/gitlab_tracker.rb @@ -0,0 +1,43 @@ +if defined? Gitlab + class IssueTrackers::GitlabTracker < IssueTracker + Label = "gitlab" + Fields = [ + [:account, { + :label => "Gitlab URL", + :placeholder => "e.g. https://example.net" + }], + [:api_token, { + :placeholder => "API Token for your account" + }], + [:project_id, { + :label => "Ticket Project Short Name / ID", + :placeholder => "Gitlab Project where issues will be created" + }] + ] + + def check_params + if Fields.detect {|f| self[f[0]].blank?} + errors.add :base, 'You must specify your Gitlab URL, API token and Project ID' + end + end + + def create_issue(problem, reported_by = nil) + Gitlab.configure do |config| + config.endpoint = "#{account}/api/v2" + config.private_token = api_token + config.user_agent = 'Errbit User Agent' + end + title = issue_title problem + description = body_template.result(binding) + Gitlab.create_issue(project_id, title, { :description => description, :labels => "errbit" } ) + end + + def body_template + @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/gitlab_body.txt.erb").gsub(/^\s*/, '')) + end + + def url + "#{account}/#{project_id}/issues" + end + end +end diff --git a/app/views/issue_trackers/gitlab_body.txt.erb b/app/views/issue_trackers/gitlab_body.txt.erb new file mode 100644 index 0000000..3c01a35 --- /dev/null +++ b/app/views/issue_trackers/gitlab_body.txt.erb @@ -0,0 +1,45 @@ +[See this exception on Errbit](<%= app_problem_url problem.app, problem %> "See this exception on Errbit") +<% if notice = problem.notices.first %> +# <%= notice.message %> # +## Summary ## +<% if notice.request['url'].present? %> + ### URL ### + [<%= notice.request['url'] %>](<%= notice.request['url'] %>)" +<% end %> +### Where ### +<%= notice.where %> + +### Occured ### +<%= notice.created_at.to_s(:micro) %> + +### Similar ### +<%= (notice.problem.notices_count - 1).to_s %> + +## Params ## +``` +<%= pretty_hash(notice.params) %> +``` + +## Session ## +``` +<%= pretty_hash(notice.session) %> +``` + +## Backtrace ## +``` +<% notice.backtrace_lines.each do |line| %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>** +<% end %> +``` + +## Environment ## + +
<%= key %>: | +<%= val %> | +