errbit_jira_plugin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac03a27f0b1c310f07d3b8152f86cfefa812eafd
4
+ data.tar.gz: 231c907c878239f20b6f0f96daa2a47130ed82d9
5
+ SHA512:
6
+ metadata.gz: af8bc6820488ee143ef4ff2755ba2fff568a2ef6f076c6b2dc4db26a1ee9ddc04b5d08c57f48e1cdd5b71ab279b9c848dd1d197e52d85edcd710b17cc45b15c3
7
+ data.tar.gz: 11167e929d1cce9d68ac788c2164d82052b2d52d917cc5741290a374dace1454b7d7f92f2ec720f39bd7ad5bf776399c6c93e63e1c19540a8fdbe0247ba3d531
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in errbit_bitbucket_plugin.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matthew McFarling
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # ErrbitJiraPlugin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'errbit_jira_plugin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install errbit_jira_plugin
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/errbit_bitbucket_plugin/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'errbit_jira_plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "errbit_jira_plugin"
8
+ spec.version = ErrbitJiraPlugin::VERSION
9
+ spec.authors = ["Matthew McFarling"]
10
+ spec.email = ["matt@codemancode.com"]
11
+ spec.summary = %q{Jira integration for Errbit.}
12
+ spec.description = %q{Jira integration for Errbit.}
13
+ spec.homepage = "https://github.com/codemancode/errbit_jira_plugin"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "errbit_plugin"
22
+ spec.add_dependency "jira-ruby"
23
+ #spec.add_dependency "faraday", "~> 0.8.1"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,12 @@
1
+ require 'errbit_jira_plugin/version'
2
+ require 'errbit_jira_plugin/error'
3
+ require 'errbit_jira_plugin/issue_tracker'
4
+ require 'errbit_jira_plugin/rails'
5
+
6
+ module ErrbitJiraPlugin
7
+ def self.root
8
+ File.expand_path '../..', __FILE__
9
+ end
10
+ end
11
+
12
+ ErrbitPlugin::Registry.add_issue_tracker(ErrbitJiraPlugin::IssueTracker)
@@ -0,0 +1,3 @@
1
+ module ErrbitJiraPlugin
2
+ class IssueError < Exception; end
3
+ end
@@ -0,0 +1,115 @@
1
+ require 'jira'
2
+
3
+ module ErrbitJiraPlugin
4
+ class IssueTracker < ErrbitPlugin::IssueTracker
5
+ LABEL = 'jira'
6
+
7
+ NOTE = 'Please configure Jira by entering the information below.'
8
+
9
+ FIELDS = [
10
+ [:base_url, {
11
+ :label => 'Jira URL without trailing slash',
12
+ :placeholder => 'https://jira.example.org'
13
+ }],
14
+ [:context_path, {
15
+ :optional => true,
16
+ :label => 'Context Path (Just "/" if empty otherwise with leading slash)',
17
+ :placeholder => "/jira"
18
+ }],
19
+ [:username, {
20
+ :label => 'Username',
21
+ :placeholder => 'johndoe'
22
+ }],
23
+ [:password, {
24
+ :label => 'Password',
25
+ :placeholder => 'p@assW0rd'
26
+ }],
27
+ [:project_id, {
28
+ :label => 'Project Key',
29
+ :placeholder => 'The project Key where the issue will be created'
30
+ }],
31
+ [:issue_priority, {
32
+ :label => 'Priority',
33
+ :placeholder => 'Normal'
34
+ }]
35
+ ]
36
+
37
+ def self.label
38
+ LABEL
39
+ end
40
+
41
+ def self.note
42
+ NOTE
43
+ end
44
+
45
+ def self.fields
46
+ FIELDS
47
+ end
48
+
49
+ def self.body_template
50
+ @body_template ||= ERB.new(File.read(
51
+ File.join(
52
+ ErrbitJiraPlugin.root, 'views', 'jira_issues_body.txt.erb'
53
+ )
54
+ ))
55
+ end
56
+
57
+ def configured?
58
+ params['project_id'].present?
59
+ end
60
+
61
+ def errors
62
+ errors = []
63
+ if self.class.fields.detect {|f| params[f[0]].blank? && !f[1][:optional]}
64
+ errors << [:base, 'You must specify all non optional values!']
65
+ end
66
+ errors
67
+ end
68
+
69
+ def comments_allowed?
70
+ false
71
+ end
72
+
73
+ def client
74
+ options = {
75
+ :username => params['username'],
76
+ :password => params['password'],
77
+ :site => params['base_url'],
78
+ :auth_type => :basic,
79
+ :context_path => (params['context_path'] == '/') ? params['context_path'] = '' : params['context_path']
80
+ }
81
+ JIRA::Client.new(options)
82
+ end
83
+
84
+ def create_issue(problem, reported_by = nil)
85
+ begin
86
+ issue_title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}".delete!("\n")
87
+ issue_description = self.class.body_template.result(binding).unpack('C*').pack('U*')
88
+ issue = {"fields"=>{"summary"=>issue_title, "description"=>issue_description,"project"=>{"key"=>params['project_id']},"issuetype"=>{"id"=>"3"},"priority"=>{"name"=>params['issue_priority']}}}
89
+
90
+ issue_build = client.Issue.build
91
+ issue_build.save(issue)
92
+
93
+ problem.update_attributes(
94
+ :issue_link => jira_url(issue_build.key),
95
+ :issue_type => params['issue_type']
96
+ )
97
+
98
+ rescue JIRA::HTTPError
99
+ raise ErrbitJiraPlugin::IssueError, "Could not create an issue with Jira. Please check your credentials."
100
+ end
101
+ end
102
+
103
+ def jira_url(project_id)
104
+ "#{params['base_url']}#{ctx_path}browse/#{project_id}"
105
+ end
106
+
107
+ def ctx_path
108
+ (params['context_path'] == '') ? '/' : params['context_path']
109
+ end
110
+
111
+ def url
112
+ params['base_url']
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,8 @@
1
+ if defined?(Rails)
2
+ module ErrbitJiraPlugin
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module ErrbitJiraPlugin
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,43 @@
1
+ h3. [See this exception on Errbit|<%= problem.url %>]
2
+ <% if notice = problem.notices.first %>
3
+ h3. <%= notice.message %>
4
+ h2. Summary
5
+ <% if notice.request['url'].present? %>
6
+ h3. URL
7
+ [<%= notice.request['url'] %>|<%= notice.request['url'] %>]
8
+ <% end %>
9
+
10
+ h3. Where
11
+ <%= notice.where %>
12
+
13
+ h3. Occured
14
+ <%= notice.created_at.to_s(:micro) %>
15
+
16
+ h3. Similar
17
+ <%= (notice.problem.notices_count - 1).to_s %>
18
+
19
+ h3. Params
20
+ {code:title=Params|borderStyle=solid}
21
+ <%= pretty_hash(notice.params) %>
22
+ {code}
23
+
24
+
25
+ h3. Session
26
+ {code:title=Session|borderStyle=solid}
27
+ <%= pretty_hash(notice.session) %>
28
+ {code}
29
+
30
+
31
+ h3. Backtrace
32
+ {code:title=Backtrace|borderStyle=solid}
33
+ <% notice.backtrace_lines.each do |line| %>
34
+ <%= line.number %>: <%= line.file_relative %> -> <%= line.method %>
35
+ <% end %>
36
+ {code}
37
+
38
+ h3. Environment
39
+ <% for key, val in notice.env_vars %>
40
+ *<%= key %>*: <%= val %>\\
41
+ <% end %>
42
+
43
+ <% end %>
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: errbit_jira_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthew McFarling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: errbit_plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jira-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Jira integration for Errbit.
70
+ email:
71
+ - matt@codemancode.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - errbit_jira_plugin.gemspec
82
+ - lib/errbit_jira_plugin.rb
83
+ - lib/errbit_jira_plugin/error.rb
84
+ - lib/errbit_jira_plugin/issue_tracker.rb
85
+ - lib/errbit_jira_plugin/rails.rb
86
+ - lib/errbit_jira_plugin/version.rb
87
+ - vendor/assets/images/Bitbucket_create.png
88
+ - vendor/assets/images/Bitbucket_inactive.png
89
+ - views/jira_issues_body.txt.erb
90
+ homepage: https://github.com/codemancode/errbit_jira_plugin
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Jira integration for Errbit.
114
+ test_files: []