embulk-input-jira 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/embulk-input-jira.gemspec +1 -1
- data/lib/embulk/input/jira.rb +7 -0
- data/lib/embulk/input/jira_api/client.rb +14 -2
- data/spec/embulk/input/jira_spec.rb +5 -0
- metadata +35 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b94f8c8f0d052b86637546f5c195418d82b488a
|
4
|
+
data.tar.gz: 0bc976612e0c0ad6a607b2c31e811cb01fc7a9f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488a061561dd21d3929ce1cf8780a45f624f3b17101c0fd2f59d3f25a13097f7b3ebb5f5fc3576c9c0951bfbc3cf8faaf23731dee889480a919b7fc7a1c04ebb
|
7
|
+
data.tar.gz: 8a4a4ec2503b3f5d61e593339aafe575877b25f7b6aee7e546c2de51328c24b477afea400d44beee7f3e808018209d4030a1c765a4704f6da364703e64e9c351
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.2.3 - 2017-11-14
|
2
|
+
|
3
|
+
* [fixed] Add a logic to check credentials before searching issues [#49](https://github.com/treasure-data/embulk-input-jira/pull/49)
|
4
|
+
|
1
5
|
## 0.2.2 - 2017-08-29
|
2
6
|
|
3
7
|
* [fixed] Added retry block to fix jiralicious authentication session [#48](https://github.com/treasure-data/embulk-input-jira/pull/48)
|
data/embulk-input-jira.gemspec
CHANGED
data/lib/embulk/input/jira.rb
CHANGED
@@ -62,6 +62,9 @@ module Embulk
|
|
62
62
|
retry_initial_wait_sec = config.param(:retry_initial_wait_sec, :integer, default: 1)
|
63
63
|
retryer = retryer(retry_limit, retry_initial_wait_sec)
|
64
64
|
|
65
|
+
# Get credential before going to search issue
|
66
|
+
jira.check_user_credential(username)
|
67
|
+
|
65
68
|
# TODO: we use 0..10 issues to guess config?
|
66
69
|
records = retryer.with_retry do
|
67
70
|
jira.search_issues(jql, max_results: GUESS_RECORDS_COUNT).map do |issue|
|
@@ -93,6 +96,8 @@ module Embulk
|
|
93
96
|
|
94
97
|
def run
|
95
98
|
return preview if preview?
|
99
|
+
|
100
|
+
@jira.check_user_credential(task[:username])
|
96
101
|
options = {}
|
97
102
|
total_count = @jira.total_count(@jql)
|
98
103
|
last_page = (total_count.to_f / PER_PAGE).ceil
|
@@ -136,6 +141,8 @@ module Embulk
|
|
136
141
|
private
|
137
142
|
|
138
143
|
def preview
|
144
|
+
@jira.check_user_credential(task[:username])
|
145
|
+
|
139
146
|
logger.debug "For preview mode, JIRA input plugin fetches records at most #{PREVIEW_RECORDS_COUNT}"
|
140
147
|
@jira.search_issues(@jql, max_results: PREVIEW_RECORDS_COUNT).each do |issue|
|
141
148
|
values = @attributes.map do |(attribute_name, type)|
|
@@ -40,6 +40,19 @@ module Embulk
|
|
40
40
|
search(jql, max_results: 1).num_results
|
41
41
|
end
|
42
42
|
|
43
|
+
def check_user_credential(username)
|
44
|
+
Jiralicious::Issue.find(username)
|
45
|
+
rescue Jiralicious::JqlError, Jiralicious::AuthenticationError, Jiralicious::NotLoggedIn, Jiralicious::InvalidLogin => e
|
46
|
+
raise Embulk::ConfigError.new(e.message)
|
47
|
+
rescue ::SocketError => e
|
48
|
+
# wrong `uri` option given
|
49
|
+
raise Embulk::ConfigError.new(e.message)
|
50
|
+
rescue MultiJson::ParseError => e
|
51
|
+
html = e.message
|
52
|
+
title = html[%r|<title>(.*?)</title>|, 1] #=> e.g. "Unauthorized (401)"
|
53
|
+
raise ConfigError.new("Can not authorize with your credential.") if title == 'Unauthorized (401)'
|
54
|
+
end
|
55
|
+
|
43
56
|
private
|
44
57
|
|
45
58
|
def timeout_and_retry(wait, retry_times = DEFAULT_SEARCH_RETRY_TIMES, &block)
|
@@ -61,13 +74,12 @@ module Embulk
|
|
61
74
|
title = html[%r|<title>(.*?)</title>|, 1] #=> e.g. "Unauthorized (401)"
|
62
75
|
if title
|
63
76
|
# (a)
|
64
|
-
Embulk.logger.warn "JIRA returns HTML: #{html}"
|
65
77
|
case title
|
66
78
|
when "Atlassian Cloud Notifications - Page Unavailable"
|
67
79
|
# a.k.a. HTTP 503
|
68
80
|
raise title
|
69
81
|
when "Unauthorized (401)"
|
70
|
-
Embulk.logger.warn "JIRA returns error: #{title}"
|
82
|
+
Embulk.logger.warn "JIRA returns error: #{title}. Will go to retry"
|
71
83
|
count += 1
|
72
84
|
retry
|
73
85
|
end
|
@@ -131,6 +131,7 @@ describe Embulk::Input::Jira do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
before do
|
134
|
+
allow(jira_api).to receive(:check_user_credential).with(username).and_return(username)
|
134
135
|
allow(jira_api).to receive(:search_issues).with(jql, max_results: described_class::GUESS_RECORDS_COUNT).and_return(jira_issues)
|
135
136
|
|
136
137
|
allow(config).to receive(:param).with(:username, :string).and_return(username)
|
@@ -211,12 +212,14 @@ describe Embulk::Input::Jira do
|
|
211
212
|
end
|
212
213
|
|
213
214
|
let(:commit_report) { {} }
|
215
|
+
let(:username) { "jira-user" }
|
214
216
|
|
215
217
|
before do
|
216
218
|
allow(jira_api).to receive(:preview?).and_return(false)
|
217
219
|
|
218
220
|
# TODO: create stubs without each `it` expected
|
219
221
|
allow(Embulk::Input::JiraApi::Client).to receive(:setup).and_return(jira_api)
|
222
|
+
allow(jira_api).to receive(:check_user_credential).and_return(username)
|
220
223
|
|
221
224
|
0.step(total_count, max_result) do |start_at|
|
222
225
|
issues = jira_issues[start_at..(start_at + max_result - 1)]
|
@@ -256,6 +259,7 @@ describe Embulk::Input::Jira do
|
|
256
259
|
let(:page_builder) { double("page_builder") }
|
257
260
|
let(:jira_api) { Embulk::Input::JiraApi::Client.new }
|
258
261
|
let(:jira_issues) { [Embulk::Input::JiraApi::Issue.new(attributes)] }
|
262
|
+
let(:username) { "jira-user" }
|
259
263
|
let(:attributes) do
|
260
264
|
{
|
261
265
|
"id" => "100",
|
@@ -281,6 +285,7 @@ describe Embulk::Input::Jira do
|
|
281
285
|
allow(Embulk::Input::JiraApi::Client).to receive(:setup).and_return(jira_api)
|
282
286
|
allow(plugin).to receive(:logger).and_return(::Logger.new(File::NULL))
|
283
287
|
allow(plugin).to receive(:preview?).and_return(true)
|
288
|
+
allow(jira_api).to receive(:check_user_credential).and_return(username)
|
284
289
|
allow(jira_api).to receive(:search_issues).and_return(jira_issues)
|
285
290
|
allow(page_builder).to receive(:add)
|
286
291
|
allow(page_builder).to receive(:finish)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-jira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
@@ -9,162 +9,162 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
name: jiralicious
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: 0.5.0
|
20
|
-
name: jiralicious
|
21
|
-
prerelease: false
|
22
|
-
type: :runtime
|
23
21
|
version_requirements: !ruby/object:Gem::Requirement
|
24
22
|
requirements:
|
25
23
|
- - "~>"
|
26
24
|
- !ruby/object:Gem::Version
|
27
25
|
version: 0.5.0
|
26
|
+
prerelease: false
|
27
|
+
type: :runtime
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
+
name: parallel
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: 1.6.0
|
34
|
-
name: parallel
|
35
|
-
prerelease: false
|
36
|
-
type: :runtime
|
37
35
|
version_requirements: !ruby/object:Gem::Requirement
|
38
36
|
requirements:
|
39
37
|
- - "~>"
|
40
38
|
- !ruby/object:Gem::Version
|
41
39
|
version: 1.6.0
|
40
|
+
prerelease: false
|
41
|
+
type: :runtime
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
+
name: perfect_retry
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
46
|
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '0.3'
|
48
|
-
name: perfect_retry
|
49
|
-
prerelease: false
|
50
|
-
type: :runtime
|
51
49
|
version_requirements: !ruby/object:Gem::Requirement
|
52
50
|
requirements:
|
53
51
|
- - "~>"
|
54
52
|
- !ruby/object:Gem::Version
|
55
53
|
version: '0.3'
|
54
|
+
prerelease: false
|
55
|
+
type: :runtime
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '1.0'
|
62
|
-
name: bundler
|
63
|
-
prerelease: false
|
64
|
-
type: :development
|
65
63
|
version_requirements: !ruby/object:Gem::Requirement
|
66
64
|
requirements:
|
67
65
|
- - "~>"
|
68
66
|
- !ruby/object:Gem::Version
|
69
67
|
version: '1.0'
|
68
|
+
prerelease: false
|
69
|
+
type: :development
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
74
|
- - "<"
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '11.0'
|
76
|
-
name: rake
|
77
|
-
prerelease: false
|
78
|
-
type: :development
|
79
77
|
version_requirements: !ruby/object:Gem::Requirement
|
80
78
|
requirements:
|
81
79
|
- - "<"
|
82
80
|
- !ruby/object:Gem::Version
|
83
81
|
version: '11.0'
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
88
|
- - "~>"
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: 3.2.0
|
90
|
-
name: rspec
|
91
|
-
prerelease: false
|
92
|
-
type: :development
|
93
91
|
version_requirements: !ruby/object:Gem::Requirement
|
94
92
|
requirements:
|
95
93
|
- - "~>"
|
96
94
|
- !ruby/object:Gem::Version
|
97
95
|
version: 3.2.0
|
96
|
+
prerelease: false
|
97
|
+
type: :development
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
+
name: embulk
|
99
100
|
requirement: !ruby/object:Gem::Requirement
|
100
101
|
requirements:
|
101
102
|
- - "~>"
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: 0.8.7
|
104
|
-
name: embulk
|
105
|
-
prerelease: false
|
106
|
-
type: :development
|
107
105
|
version_requirements: !ruby/object:Gem::Requirement
|
108
106
|
requirements:
|
109
107
|
- - "~>"
|
110
108
|
- !ruby/object:Gem::Version
|
111
109
|
version: 0.8.7
|
110
|
+
prerelease: false
|
111
|
+
type: :development
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
+
name: simplecov
|
113
114
|
requirement: !ruby/object:Gem::Requirement
|
114
115
|
requirements:
|
115
116
|
- - ">="
|
116
117
|
- !ruby/object:Gem::Version
|
117
118
|
version: '0'
|
118
|
-
name: simplecov
|
119
|
-
prerelease: false
|
120
|
-
type: :development
|
121
119
|
version_requirements: !ruby/object:Gem::Requirement
|
122
120
|
requirements:
|
123
121
|
- - ">="
|
124
122
|
- !ruby/object:Gem::Version
|
125
123
|
version: '0'
|
124
|
+
prerelease: false
|
125
|
+
type: :development
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
+
name: pry
|
127
128
|
requirement: !ruby/object:Gem::Requirement
|
128
129
|
requirements:
|
129
130
|
- - ">="
|
130
131
|
- !ruby/object:Gem::Version
|
131
132
|
version: '0'
|
132
|
-
name: pry
|
133
|
-
prerelease: false
|
134
|
-
type: :development
|
135
133
|
version_requirements: !ruby/object:Gem::Requirement
|
136
134
|
requirements:
|
137
135
|
- - ">="
|
138
136
|
- !ruby/object:Gem::Version
|
139
137
|
version: '0'
|
138
|
+
prerelease: false
|
139
|
+
type: :development
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
+
name: codeclimate-test-reporter
|
141
142
|
requirement: !ruby/object:Gem::Requirement
|
142
143
|
requirements:
|
143
144
|
- - ">="
|
144
145
|
- !ruby/object:Gem::Version
|
145
146
|
version: '0'
|
146
|
-
name: codeclimate-test-reporter
|
147
|
-
prerelease: false
|
148
|
-
type: :development
|
149
147
|
version_requirements: !ruby/object:Gem::Requirement
|
150
148
|
requirements:
|
151
149
|
- - ">="
|
152
150
|
- !ruby/object:Gem::Version
|
153
151
|
version: '0'
|
152
|
+
prerelease: false
|
153
|
+
type: :development
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
|
+
name: everyleaf-embulk_helper
|
155
156
|
requirement: !ruby/object:Gem::Requirement
|
156
157
|
requirements:
|
157
158
|
- - ">="
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
|
-
name: everyleaf-embulk_helper
|
161
|
-
prerelease: false
|
162
|
-
type: :development
|
163
161
|
version_requirements: !ruby/object:Gem::Requirement
|
164
162
|
requirements:
|
165
163
|
- - ">="
|
166
164
|
- !ruby/object:Gem::Version
|
167
165
|
version: '0'
|
166
|
+
prerelease: false
|
167
|
+
type: :development
|
168
168
|
description: Loads records from Jira.
|
169
169
|
email:
|
170
170
|
- k@uu59.org
|