Commit 72e110325f3ed56dffe9b6ce2323d1e374de4381

Authored by Jozef Vaclavik
1 parent 8a291c12
Exists in master and in 1 other branch production

Updating Gitlab Integration for New API (v3) Gemfile update

Gemfile
... ... @@ -37,7 +37,7 @@ gem 'ruby-fogbugz', :require => 'fogbugz'
37 37 # Github Issues
38 38 gem 'octokit', '~> 1.0.0'
39 39 # Gitlab
40   -gem 'gitlab'
  40 +gem 'gitlab', :git => 'git://github.com/NARKOZ/gitlab'
41 41  
42 42 # Bitbucket Issues
43 43 gem 'bitbucket_rest_api'
... ...
Gemfile.lock
  1 +GIT
  2 + remote: git://github.com/NARKOZ/gitlab
  3 + revision: e4d7dd7dd4be587e44de388eb64d164cab5d464f
  4 + specs:
  5 + gitlab (2.2.0)
  6 + httparty
  7 +
1 8 GEM
2 9 remote: http://rubygems.org/
3 10 specs:
... ... @@ -99,8 +106,6 @@ GEM
99 106 ffi (1.1.4)
100 107 foreman (0.60.2)
101 108 thor (>= 0.13.6)
102   - gitlab (2.1.0)
103   - httparty
104 109 haml (3.1.6)
105 110 happymapper (0.4.0)
106 111 libxml-ruby (~> 2.0)
... ...
app/models/issue_trackers/gitlab_tracker.rb
... ... @@ -10,7 +10,7 @@ if defined? Gitlab
10 10 :placeholder => "API Token for your account"
11 11 }],
12 12 [:project_id, {
13   - :label => "Ticket Project Short Name / ID",
  13 + :label => "Ticket Project ID (use Number)",
14 14 :placeholder => "Gitlab Project where issues will be created"
15 15 }]
16 16 ]
... ... @@ -23,19 +23,25 @@ if defined? Gitlab
23 23  
24 24 def create_issue(problem, reported_by = nil)
25 25 Gitlab.configure do |config|
26   - config.endpoint = "#{account}/api/v2"
  26 + config.endpoint = "#{account}/api/v3"
27 27 config.private_token = api_token
28 28 config.user_agent = 'Errbit User Agent'
29 29 end
30 30 title = issue_title problem
31   - description = body_template.result(binding)
32   - Gitlab.create_issue(project_id, title, { :description => description, :labels => "errbit" } )
  31 + description_summary = summary_template.result(binding)
  32 + description_body = body_template.result(binding)
  33 + ticket = Gitlab.create_issue(project_id, title, { :description => description_summary, :labels => "errbit" } )
  34 + Gitlab.create_issue_note(project_id, ticket.id, description_body)
33 35 end
34 36  
  37 + def summary_template
  38 + @@summary_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/gitlab_summary.txt.erb").gsub(/^\s*/, ''))
  39 +
  40 + end
35 41 def body_template
36 42 @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/gitlab_body.txt.erb").gsub(/^\s*/, ''))
37 43 end
38   -
  44 +
39 45 def url
40 46 "#{account}/#{project_id}/issues"
41 47 end
... ...
app/views/issue_trackers/gitlab_body.txt.erb
1   -[See this exception on Errbit](<%= app_problem_url problem.app, problem %> "See this exception on Errbit")
2 1 <% if notice = problem.notices.first %>
3   -# <%= notice.message %> #
4   -## Summary ##
5   -<% if notice.request['url'].present? %>
6   - ### URL ###
7   - [<%= notice.request['url'] %>](<%= notice.request['url'] %>)"
8   -<% end %>
9   -### Where ###
10   -<%= notice.where %>
11   -
12   -### Occured ###
13   -<%= notice.created_at.to_s(:micro) %>
14   -
15   -### Similar ###
16   -<%= (notice.problem.notices_count - 1).to_s %>
17   -
18 2 ## Params ##
19 3 ```
20 4 <%= pretty_hash(notice.params) %>
... ...