jpsclient 2.7.1 → 2.7.3
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 +4 -4
- data/lib/jpsclient/api/commit_log.rb +14 -14
- data/lib/jpsclient/http/http_client.rb +5 -1
- data/lib/jpsclient/upload/upload_client.rb +31 -1
- data/lib/jpsclient/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e190dad3a9fb10f985ea2536b22c03de35927a45bb26a45ce6ce4e49a87b13d
|
|
4
|
+
data.tar.gz: c7a7c41fab362a5f0bfdddbac0e0a4a75de2ded745a601787dd9a98e34e046df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4ef3da2ea5cc2c413213722d2d529a1f93ed334d1739d817d8eadc2faa5945c8783737f6200095e315f227456c7b2fe0d341a0262e9a9facba32ca671824ae0
|
|
7
|
+
data.tar.gz: 75a7071f7117f8e15a7b4cca95dbd88dfaf1a116513b735b301e6a23bccd1c75535ae6313f52f96191fb2c3971f8a6399a3c379b8f802cc5e3eb3842c571c09b
|
|
@@ -27,18 +27,21 @@ module JPSClient
|
|
|
27
27
|
return request_with_auth(:post, path, body: body_params)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
#
|
|
30
|
+
# 发送提交记录消息通知(commit_log/send_message)
|
|
31
|
+
#
|
|
32
|
+
# 以线上真实请求为准:接口文档可能滞后。
|
|
31
33
|
#
|
|
32
34
|
# @param projectId [String] 项目ID(必需)
|
|
33
35
|
# @param workflowId [Integer] 工作流ID(必需)
|
|
34
36
|
# @param params [Hash] 其他参数
|
|
35
|
-
# @option params [Boolean] :single
|
|
36
|
-
# @option params [Array<
|
|
37
|
-
# @option params [String] :branch
|
|
38
|
-
# @option params [Array<String>] :commitIds 提交ID
|
|
39
|
-
# @option params [Integer] :startTimestamp
|
|
40
|
-
# @option params [Integer] :endTimestamp
|
|
41
|
-
# @option params [Integer] :indexNo
|
|
37
|
+
# @option params [Boolean] :single 是否单条提交发送(默认 true)
|
|
38
|
+
# @option params [Array<Integer>] :ids commit_log 记录 ID 集合
|
|
39
|
+
# @option params [String] :branch 分支名称,空字符串也需要原样发送
|
|
40
|
+
# @option params [Array<String>] :commitIds 提交ID集合,single=true 时必传(取第一个)
|
|
41
|
+
# @option params [Integer] :startTimestamp 提交时间下界(epoch 毫秒,闭区间,仅 single=false)
|
|
42
|
+
# @option params [Integer] :endTimestamp 提交时间上界(epoch 毫秒,开区间,仅 single=false)
|
|
43
|
+
# @option params [Integer] :indexNo 项目包索引号
|
|
44
|
+
# @option params [Array<String>] :repoTypes 仓库类型过滤(仅 single=false)
|
|
42
45
|
# @return [Hash] API响应
|
|
43
46
|
def send_commit_log_message(projectId:, workflowId:, params: {})
|
|
44
47
|
config = @request_config && @request_config["commit_log_send_message"]
|
|
@@ -51,16 +54,13 @@ module JPSClient
|
|
|
51
54
|
single: params.fetch(:single, true)
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
# 服务端 CommitLogSendMessageDto 只有 branches 数组字段,branch 单数会被直接丢弃,
|
|
56
|
-
# 因此单数写法在这里归一化为数组,不再原样透传
|
|
57
|
-
branches = params[:branches] || params[:branch]
|
|
58
|
-
body_params[:branches] = Array(branches).compact if branches
|
|
59
|
-
|
|
57
|
+
body_params[:ids] = params[:ids] if params[:ids]
|
|
60
58
|
body_params[:commitIds] = params[:commitIds] if params[:commitIds]
|
|
59
|
+
body_params[:branch] = params[:branch] if params.key?(:branch)
|
|
61
60
|
body_params[:startTimestamp] = params[:startTimestamp] if params[:startTimestamp]
|
|
62
61
|
body_params[:endTimestamp] = params[:endTimestamp] if params[:endTimestamp]
|
|
63
62
|
body_params[:indexNo] = params[:indexNo] if params[:indexNo]
|
|
63
|
+
body_params[:repoTypes] = params[:repoTypes] if params[:repoTypes]
|
|
64
64
|
|
|
65
65
|
return request_with_auth(:post, path, body: body_params)
|
|
66
66
|
end
|
|
@@ -236,6 +236,10 @@ end
|
|
|
236
236
|
module JPSClient
|
|
237
237
|
# JPS API 响应封装类 - 简化版
|
|
238
238
|
class Response
|
|
239
|
+
# 登录 token 失效的业务码。调用方需要按它区分「认证失败」和「网络/服务端故障」,
|
|
240
|
+
# 提成常量避免各处硬编码
|
|
241
|
+
NEED_LOGIN_CODE = '20001'.freeze
|
|
242
|
+
|
|
239
243
|
attr_reader :code
|
|
240
244
|
attr_reader :data
|
|
241
245
|
attr_reader :msg
|
|
@@ -269,7 +273,7 @@ module JPSClient
|
|
|
269
273
|
|
|
270
274
|
# 20001: 登录token失效
|
|
271
275
|
def need_login?
|
|
272
|
-
@need_login || @code.to_s ==
|
|
276
|
+
@need_login || @code.to_s == NEED_LOGIN_CODE
|
|
273
277
|
end
|
|
274
278
|
|
|
275
279
|
# 20011: 没有权限访问项目
|
|
@@ -6,6 +6,7 @@ require 'digest'
|
|
|
6
6
|
require 'cgi'
|
|
7
7
|
require 'uri'
|
|
8
8
|
require 'jpsclient/base/exception'
|
|
9
|
+
require 'jpsclient/http/http_client'
|
|
9
10
|
require 'jpsclient/upload/upload_config'
|
|
10
11
|
require 'jpsclient/upload/upload_progress'
|
|
11
12
|
require 'jpsclient/utils/logger'
|
|
@@ -98,7 +99,7 @@ module JPSClient
|
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
if init_result.nil? || !init_result.dig("data", "upload_id")
|
|
101
|
-
raise ExceptionError,
|
|
102
|
+
raise ExceptionError, init_multipart_error_message(init_result)
|
|
102
103
|
end
|
|
103
104
|
|
|
104
105
|
upload_id = init_result["data"]["upload_id"]
|
|
@@ -169,6 +170,35 @@ module JPSClient
|
|
|
169
170
|
|
|
170
171
|
end
|
|
171
172
|
|
|
173
|
+
# 拼装初始化上传失败的错误信息
|
|
174
|
+
#
|
|
175
|
+
# 真实原因写在接口返回的 code / msg 里(例如 20001 登录态失效),
|
|
176
|
+
# 一律报「请检查网络或服务器状态」会把认证问题误导成网络问题;
|
|
177
|
+
# 而原始响应此前只在 JPSClient.debug? 下打印,排查时通常拿不到。
|
|
178
|
+
#
|
|
179
|
+
# @param init_result [Hash, nil] init_file_multipart 的原始返回
|
|
180
|
+
# @return [String] 带上真实原因的错误信息
|
|
181
|
+
def init_multipart_error_message(init_result)
|
|
182
|
+
return "初始化上传失败:接口无响应,请检查网络或服务器状态" if init_result.nil?
|
|
183
|
+
|
|
184
|
+
code = init_result["code"]
|
|
185
|
+
msg = init_result["msg"] || init_result["message"]
|
|
186
|
+
|
|
187
|
+
# request_with_auth 遇到 20001 会自动重新登录并重试一次,
|
|
188
|
+
# 这里仍拿到 20001 说明重登也没成功,需要用户手动重新登录
|
|
189
|
+
if code.to_s == Response::NEED_LOGIN_CODE
|
|
190
|
+
detail = msg.to_s.empty? ? "code=#{code}" : "code=#{code},msg=#{msg}"
|
|
191
|
+
return "初始化上传失败:登录态已失效,且自动重新登录未成功(#{detail}),请重新登录后重试"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
parts = []
|
|
195
|
+
parts << "code=#{code}" unless code.nil?
|
|
196
|
+
parts << "msg=#{msg}" unless msg.to_s.empty?
|
|
197
|
+
parts << "响应中缺少 data.upload_id" if parts.empty?
|
|
198
|
+
|
|
199
|
+
"初始化上传失败(#{parts.join(",")}),请检查网络或服务器状态"
|
|
200
|
+
end
|
|
201
|
+
|
|
172
202
|
# 安全地检查上传失败状态
|
|
173
203
|
def upload_failed?
|
|
174
204
|
@upload_failed_mutex.synchronize { @upload_failed }
|
data/lib/jpsclient/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jpsclient
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.7.
|
|
4
|
+
version: 2.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Your Name
|
|
@@ -296,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
296
296
|
- !ruby/object:Gem::Version
|
|
297
297
|
version: '0'
|
|
298
298
|
requirements: []
|
|
299
|
-
rubygems_version: 4.0.
|
|
299
|
+
rubygems_version: 4.0.10
|
|
300
300
|
specification_version: 4
|
|
301
301
|
summary: JPS Platform API Client with Full API Support
|
|
302
302
|
test_files: []
|