pindo 5.11.3 → 5.12.1
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/pindo/command/android/autobuild.rb +111 -184
- data/lib/pindo/command/android/build.rb +10 -2
- data/lib/pindo/command/ios/autobuild.rb +115 -210
- data/lib/pindo/command/ios/build.rb +12 -3
- data/lib/pindo/command/jps/upload.rb +257 -117
- data/lib/pindo/command/unity/autobuild.rb +308 -220
- data/lib/pindo/command/unity.rb +0 -3
- data/lib/pindo/command/utils/boss.rb +18 -15
- data/lib/pindo/command/utils/clearcert.rb +26 -18
- data/lib/pindo/command/utils/device.rb +28 -19
- data/lib/pindo/command/utils/feishu.rb +11 -4
- data/lib/pindo/command/utils/icon.rb +26 -20
- data/lib/pindo/command/utils/renewcert.rb +35 -29
- data/lib/pindo/command/utils/renewproj.rb +32 -25
- data/lib/pindo/command/utils/repoinit.rb +1 -1
- data/lib/pindo/command/utils/tag.rb +6 -180
- data/lib/pindo/command/utils/tgate.rb +34 -28
- data/lib/pindo/command/utils/xcassets.rb +30 -20
- data/lib/pindo/command/web/autobuild.rb +148 -128
- data/lib/pindo/module/android/android_build_helper.rb +0 -6
- data/lib/pindo/module/android/android_config_helper.rb +4 -26
- data/lib/pindo/module/build/build_helper.rb +18 -294
- data/lib/pindo/module/build/git_repo_helper.rb +519 -0
- data/lib/pindo/module/build/icon_downloader.rb +85 -0
- data/lib/pindo/module/pgyer/pgyerhelper.rb +16 -11
- data/lib/pindo/module/task/model/build/android_dev_build_task.rb +209 -0
- data/lib/pindo/module/task/model/build/android_release_build_task.rb +29 -0
- data/lib/pindo/module/task/model/build/ios_adhoc_build_task.rb +53 -0
- data/lib/pindo/module/task/model/build/ios_dev_build_task.rb +251 -0
- data/lib/pindo/module/task/model/build/ios_release_build_task.rb +53 -0
- data/lib/pindo/module/task/model/build/web_dev_build_task.rb +43 -0
- data/lib/pindo/module/task/model/build_task.rb +125 -301
- data/lib/pindo/module/task/model/git_tag_task.rb +80 -0
- data/lib/pindo/module/task/model/unity_export_task.rb +53 -41
- data/lib/pindo/module/task/model/upload_task.rb +149 -208
- data/lib/pindo/module/task/pindo_task.rb +135 -95
- data/lib/pindo/module/task/task_manager.rb +202 -352
- data/lib/pindo/module/unity/unity_helper.rb +7 -3
- data/lib/pindo/module/xcode/xcode_build_config.rb +4 -10
- data/lib/pindo/module/xcode/xcode_build_helper.rb +19 -0
- data/lib/pindo/version.rb +1 -1
- metadata +10 -4
- data/lib/pindo/command/unity/apk.rb +0 -185
- data/lib/pindo/command/unity/ipa.rb +0 -198
- data/lib/pindo/command/unity/web.rb +0 -163
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative '../pindo_task'
|
|
2
|
+
require 'pindo/base/funlog'
|
|
2
3
|
|
|
3
4
|
module Pindo
|
|
4
5
|
module TaskSystem
|
|
@@ -9,21 +10,27 @@ module Pindo
|
|
|
9
10
|
:unity_export
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
# 重试配置
|
|
14
|
+
def self.default_retry_mode
|
|
15
|
+
RetryMode::DELAYED
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
def self.
|
|
17
|
-
|
|
18
|
+
def self.default_retry_count
|
|
19
|
+
2 # 可以重试 2 次
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.default_retry_delay
|
|
23
|
+
10 # 延迟 10 秒
|
|
18
24
|
end
|
|
19
25
|
|
|
20
26
|
def initialize(platform, options = {})
|
|
21
27
|
@platform = platform
|
|
22
28
|
@unity_project_path = options[:project_path] || Dir.pwd
|
|
23
|
-
@unity_exe_path =
|
|
24
|
-
@unity_helper =
|
|
25
|
-
@is_library_mode =
|
|
26
|
-
@
|
|
29
|
+
@unity_exe_path = nil # 将在 do_work 中自动查找
|
|
30
|
+
@unity_helper = nil # 将在 do_work 中自动初始化
|
|
31
|
+
@is_library_mode = false # 不再支持库模式
|
|
32
|
+
@index_count = options[:context] ? options[:context][:index_count] : nil
|
|
33
|
+
@export_path = options[:export_path] # 可由参数传入,nil 表示自动检测
|
|
27
34
|
|
|
28
35
|
name = case platform
|
|
29
36
|
when 'ios', 'ipa'
|
|
@@ -56,18 +63,14 @@ module Pindo
|
|
|
56
63
|
protected
|
|
57
64
|
|
|
58
65
|
def do_work
|
|
59
|
-
update_progress(0, "启动 Unity...")
|
|
60
|
-
|
|
61
66
|
# 确保 Unity helper 已初始化
|
|
62
67
|
@unity_helper ||= Pindo::Client::UnityHelper.share_instance
|
|
63
68
|
|
|
64
69
|
# 获取 Unity 版本
|
|
65
|
-
update_progress(10, "检查 Unity 版本...")
|
|
66
70
|
project_unity_version = @unity_helper.get_unity_version(@unity_project_path)
|
|
67
71
|
|
|
68
72
|
# 查找 Unity 执行路径
|
|
69
73
|
unless @unity_exe_path
|
|
70
|
-
update_progress(20, "查找 Unity 路径...")
|
|
71
74
|
@unity_exe_path = @unity_helper.find_unity_path(
|
|
72
75
|
project_unity_version: project_unity_version,
|
|
73
76
|
force_change_version: false
|
|
@@ -78,11 +81,9 @@ module Pindo
|
|
|
78
81
|
raise "无法找到 Unity 执行路径"
|
|
79
82
|
end
|
|
80
83
|
|
|
81
|
-
update_progress(30, "准备 Unity 导出...")
|
|
82
|
-
|
|
83
84
|
# 显示 Unity 信息
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
Funlog.info("Unity 版本: #{project_unity_version}")
|
|
86
|
+
Funlog.info("Unity 路径: #{@unity_exe_path}")
|
|
86
87
|
|
|
87
88
|
# 执行 Unity 导出
|
|
88
89
|
case @platform
|
|
@@ -100,17 +101,26 @@ module Pindo
|
|
|
100
101
|
private
|
|
101
102
|
|
|
102
103
|
def export_ios
|
|
103
|
-
update_progress(40, "执行 Unity iOS 导出...")
|
|
104
|
-
|
|
105
104
|
platform = 'iOS'
|
|
106
|
-
result = execute_unity_build(platform)
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
# 设置导出路径(如果未指定)
|
|
107
|
+
if @export_path.nil?
|
|
108
|
+
# 优先使用 BaseiOS,如果不存在则使用 iOS
|
|
109
|
+
base_ios_path = File.join(@unity_project_path, "GoodPlatform", "BaseiOS")
|
|
110
|
+
ios_path = File.join(@unity_project_path, "GoodPlatform", "iOS")
|
|
111
|
+
|
|
112
|
+
@export_path = if File.exist?(base_ios_path)
|
|
113
|
+
base_ios_path
|
|
114
|
+
else
|
|
115
|
+
ios_path
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# 根据导出路径判断是否为库模式
|
|
120
|
+
@is_library_mode = @export_path.include?("BaseiOS")
|
|
109
121
|
|
|
110
|
-
|
|
111
|
-
@export_path = File.join(@unity_project_path, "GoodPlatform", "iOS")
|
|
122
|
+
result = execute_unity_build(platform)
|
|
112
123
|
|
|
113
|
-
update_progress(100, "Unity iOS 导出成功")
|
|
114
124
|
{
|
|
115
125
|
success: true,
|
|
116
126
|
platform: 'ios',
|
|
@@ -120,17 +130,26 @@ module Pindo
|
|
|
120
130
|
end
|
|
121
131
|
|
|
122
132
|
def export_android
|
|
123
|
-
update_progress(40, "执行 Unity Android 导出...")
|
|
124
|
-
|
|
125
133
|
platform = 'Android'
|
|
126
|
-
result = execute_unity_build(platform)
|
|
127
134
|
|
|
128
|
-
|
|
135
|
+
# 设置导出路径(如果未指定)
|
|
136
|
+
if @export_path.nil?
|
|
137
|
+
# 优先使用 BaseAndroid,如果不存在则使用 Android
|
|
138
|
+
base_android_path = File.join(@unity_project_path, "GoodPlatform", "BaseAndroid")
|
|
139
|
+
android_path = File.join(@unity_project_path, "GoodPlatform", "Android")
|
|
140
|
+
|
|
141
|
+
@export_path = if File.exist?(base_android_path)
|
|
142
|
+
base_android_path
|
|
143
|
+
else
|
|
144
|
+
android_path
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# 根据导出路径判断是否为库模式
|
|
149
|
+
@is_library_mode = @export_path.include?("BaseAndroid")
|
|
129
150
|
|
|
130
|
-
|
|
131
|
-
@export_path = File.join(@unity_project_path, "GoodPlatform", "Android")
|
|
151
|
+
result = execute_unity_build(platform)
|
|
132
152
|
|
|
133
|
-
update_progress(100, "Unity Android 导出成功")
|
|
134
153
|
{
|
|
135
154
|
success: true,
|
|
136
155
|
platform: 'android',
|
|
@@ -140,17 +159,13 @@ module Pindo
|
|
|
140
159
|
end
|
|
141
160
|
|
|
142
161
|
def export_web
|
|
143
|
-
update_progress(40, "执行 Unity WebGL 导出...")
|
|
144
|
-
|
|
145
162
|
platform = 'WebGL'
|
|
146
163
|
result = execute_unity_build(platform)
|
|
147
164
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
@export_path = File.join(@unity_project_path, "GoodPlatform", "Web")
|
|
165
|
+
# 设置导出路径(如果未指定)
|
|
166
|
+
# Web 平台只有一个目录
|
|
167
|
+
@export_path ||= File.join(@unity_project_path, "GoodPlatform", "WebGL")
|
|
152
168
|
|
|
153
|
-
update_progress(100, "Unity WebGL 导出成功")
|
|
154
169
|
{
|
|
155
170
|
success: true,
|
|
156
171
|
platform: 'web',
|
|
@@ -161,25 +176,22 @@ module Pindo
|
|
|
161
176
|
|
|
162
177
|
def execute_unity_build(platform)
|
|
163
178
|
# 检查 Unity 进程
|
|
164
|
-
update_progress(50, "检查 Unity 进程...")
|
|
165
179
|
@unity_helper.check_unity_processes(
|
|
166
180
|
unity_exe_full_path: @unity_exe_path,
|
|
167
181
|
project_path: @unity_project_path
|
|
168
182
|
)
|
|
169
183
|
|
|
170
184
|
# 执行构建
|
|
171
|
-
update_progress(60, "开始 Unity 构建...")
|
|
172
185
|
begin
|
|
173
186
|
result = @unity_helper.build_project(
|
|
174
187
|
unity_exe_full_path: @unity_exe_path,
|
|
175
188
|
project_path: @unity_project_path,
|
|
176
189
|
platform: platform,
|
|
177
190
|
isLibrary: @is_library_mode,
|
|
178
|
-
indexNo:
|
|
191
|
+
indexNo: @index_count
|
|
179
192
|
)
|
|
180
193
|
|
|
181
194
|
# 清理 Unity 进程
|
|
182
|
-
update_progress(85, "清理 Unity 进程...")
|
|
183
195
|
@unity_helper.cleanup_unity_processes_after_build(
|
|
184
196
|
unity_exe_full_path: @unity_exe_path,
|
|
185
197
|
project_path: @unity_project_path
|
|
@@ -1,278 +1,219 @@
|
|
|
1
1
|
require_relative '../pindo_task'
|
|
2
|
+
require_relative '../task_config'
|
|
3
|
+
require 'pindo/module/pgyer/pgyerhelper'
|
|
2
4
|
|
|
3
5
|
module Pindo
|
|
4
6
|
module TaskSystem
|
|
7
|
+
# 上传任务
|
|
8
|
+
# 上传构建产物到测试平台(JPS)
|
|
5
9
|
class UploadTask < PindoTask
|
|
6
|
-
attr_reader :
|
|
10
|
+
attr_reader :file_type, :upload_path, :upload_file
|
|
7
11
|
|
|
8
12
|
def self.task_type
|
|
9
13
|
:upload
|
|
10
14
|
end
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
# 重试配置
|
|
17
|
+
def self.default_retry_mode
|
|
18
|
+
RetryMode::DELAYED # 延迟重试
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
def self.
|
|
17
|
-
|
|
21
|
+
def self.default_retry_count
|
|
22
|
+
3 # 默认可以重试 3 次
|
|
18
23
|
end
|
|
19
24
|
|
|
20
|
-
def
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
def self.default_retry_delay
|
|
26
|
+
10 # 默认延迟 10 秒
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# 初始化上传任务
|
|
30
|
+
# @param file_type [String] 文件类型:'ipa' | 'apk' | 'html' | 'app'
|
|
31
|
+
# @param upload_path [String] 搜索文件的路径
|
|
32
|
+
# @param upload_file [String] 要上传的文件(nil 表示自动查找)
|
|
33
|
+
# @param options [Hash] 选项
|
|
34
|
+
# @option options [Hash] :app_info_obj JPS 应用信息对象(可选,如为 nil 则延迟获取)
|
|
35
|
+
# @option options [Hash] :workflow_info 工作流信息(可选,如为 nil 则延迟获取)
|
|
36
|
+
# @option options [String] :project_name 项目名称(可选)
|
|
37
|
+
def initialize(file_type, upload_path, upload_file, options = {})
|
|
38
|
+
@file_type = file_type # 'ipa' | 'apk' | 'html' | 'app'
|
|
39
|
+
@upload_path = upload_path # 搜索文件的路径
|
|
40
|
+
@upload_file = upload_file # 要上传的文件(nil 表示自动查找)
|
|
41
|
+
|
|
42
|
+
# 可选参数(如果为 nil,在 do_work 中延迟获取)
|
|
43
|
+
@app_info_obj = options[:app_info_obj]
|
|
44
|
+
@workflow_info = options[:workflow_info]
|
|
23
45
|
@project_name = options[:project_name]
|
|
24
|
-
@upload_helper = options[:upload_helper]
|
|
25
|
-
@upload_url = nil
|
|
26
46
|
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
# 设置上传任务的优先级为 LOW,确保在构建任务之后执行
|
|
48
|
+
options[:priority] ||= TaskPriority::LOW
|
|
49
|
+
|
|
50
|
+
name = case file_type
|
|
51
|
+
when 'ipa'
|
|
29
52
|
"上传 IPA"
|
|
30
|
-
when '
|
|
53
|
+
when 'apk'
|
|
31
54
|
"上传 APK"
|
|
32
|
-
when '
|
|
33
|
-
"上传
|
|
55
|
+
when 'html'
|
|
56
|
+
"上传 WebGL"
|
|
57
|
+
when 'app'
|
|
58
|
+
"上传 macOS App"
|
|
34
59
|
else
|
|
35
|
-
"上传 #{
|
|
60
|
+
"上传 #{file_type.upcase}"
|
|
36
61
|
end
|
|
37
62
|
|
|
38
63
|
super(name, options)
|
|
39
64
|
end
|
|
40
65
|
|
|
41
66
|
def validate
|
|
42
|
-
#
|
|
43
|
-
|
|
67
|
+
# 验证基本参数
|
|
68
|
+
unless @file_type && !@file_type.empty?
|
|
69
|
+
@error = "缺少必需参数: file_type"
|
|
70
|
+
return false
|
|
71
|
+
end
|
|
44
72
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@error = "上传文件不存在:#{@file_path}"
|
|
73
|
+
unless @upload_path && !@upload_path.empty?
|
|
74
|
+
@error = "缺少必需参数: upload_path"
|
|
48
75
|
return false
|
|
49
76
|
end
|
|
50
77
|
|
|
78
|
+
# upload_path 可能在构建任务执行后才创建,这里不验证是否存在
|
|
79
|
+
# 实际文件查找会在 do_work 中进行
|
|
80
|
+
|
|
81
|
+
# app_info_obj 和 workflow_info 可以延迟获取,不在这里验证
|
|
82
|
+
|
|
51
83
|
true
|
|
52
84
|
end
|
|
53
85
|
|
|
54
86
|
protected
|
|
55
87
|
|
|
56
88
|
def do_work
|
|
57
|
-
#
|
|
58
|
-
if @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# 再次验证文件
|
|
63
|
-
unless @file_path && File.exist?(@file_path)
|
|
64
|
-
raise "上传文件不存在或未指定:#{@file_path}"
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
update_progress(0, "准备上传...")
|
|
68
|
-
|
|
69
|
-
# 初始化上传 helper
|
|
70
|
-
@upload_helper ||= PgyerHelper.share_instace
|
|
71
|
-
|
|
72
|
-
case @platform
|
|
73
|
-
when 'ios', 'ipa'
|
|
74
|
-
upload_ipa
|
|
75
|
-
when 'android', 'apk'
|
|
76
|
-
upload_apk
|
|
77
|
-
when 'web', 'html'
|
|
78
|
-
upload_web
|
|
89
|
+
# 1. 确定上传文件
|
|
90
|
+
if @upload_file && !@upload_file.empty? && File.exist?(@upload_file)
|
|
91
|
+
# 使用指定文件
|
|
92
|
+
file_to_upload = @upload_file
|
|
93
|
+
puts " 使用指定文件: #{file_to_upload}"
|
|
79
94
|
else
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def upload_ipa
|
|
87
|
-
update_progress(10, "准备上传 IPA...")
|
|
88
|
-
|
|
89
|
-
# 获取文件大小
|
|
90
|
-
file_size = File.size(@file_path) / (1024.0 * 1024.0)
|
|
91
|
-
update_progress(20, "文件大小: #{file_size.round(2)} MB")
|
|
92
|
-
|
|
93
|
-
# 准备上传参数
|
|
94
|
-
upload_params = prepare_upload_params
|
|
95
|
-
|
|
96
|
-
update_progress(30, "开始上传到测试平台...")
|
|
97
|
-
|
|
98
|
-
# 执行上传
|
|
99
|
-
begin
|
|
100
|
-
# 模拟进度更新
|
|
101
|
-
upload_with_progress do |progress|
|
|
102
|
-
update_progress(30 + (progress * 0.6).to_i, "上传中...")
|
|
95
|
+
# 在 upload_path 下查找 file_type 类型的最新文件
|
|
96
|
+
file_to_upload = find_latest_file_by_type
|
|
97
|
+
unless file_to_upload && File.exist?(file_to_upload)
|
|
98
|
+
# 文件不存在,将重试次数设为 0,不再重试
|
|
99
|
+
@retry_count = 0
|
|
100
|
+
raise "未找到上传文件(类型: #{@file_type}, 路径: #{@upload_path})"
|
|
103
101
|
end
|
|
102
|
+
puts " 找到文件: #{file_to_upload}"
|
|
103
|
+
end
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
project_name: @project_name || upload_params[:project_name]
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
@upload_url = result[:url] if result && result[:url]
|
|
112
|
-
|
|
113
|
-
update_progress(95, "处理上传结果...")
|
|
114
|
-
rescue => e
|
|
115
|
-
raise "IPA 上传失败: #{e.message}"
|
|
105
|
+
# 2. 如果没有 JPS 配置,延迟获取
|
|
106
|
+
if @app_info_obj.nil? || @workflow_info.nil?
|
|
107
|
+
fetch_jps_config(file_to_upload)
|
|
116
108
|
end
|
|
117
109
|
|
|
118
|
-
|
|
110
|
+
# 3. 上传到 JPS
|
|
111
|
+
upload_to_jps(file_to_upload)
|
|
112
|
+
|
|
119
113
|
{
|
|
120
114
|
success: true,
|
|
121
|
-
|
|
122
|
-
file_path:
|
|
123
|
-
upload_url: @upload_url
|
|
115
|
+
file_type: @file_type,
|
|
116
|
+
file_path: file_to_upload
|
|
124
117
|
}
|
|
125
118
|
end
|
|
126
119
|
|
|
127
|
-
|
|
128
|
-
update_progress(10, "准备上传 APK...")
|
|
129
|
-
|
|
130
|
-
# 获取文件大小
|
|
131
|
-
file_size = File.size(@file_path) / (1024.0 * 1024.0)
|
|
132
|
-
update_progress(20, "文件大小: #{file_size.round(2)} MB")
|
|
133
|
-
|
|
134
|
-
# 准备上传参数
|
|
135
|
-
upload_params = prepare_upload_params
|
|
136
|
-
|
|
137
|
-
update_progress(30, "开始上传到测试平台...")
|
|
138
|
-
|
|
139
|
-
# 执行上传
|
|
140
|
-
begin
|
|
141
|
-
# 模拟进度更新
|
|
142
|
-
upload_with_progress do |progress|
|
|
143
|
-
update_progress(30 + (progress * 0.6).to_i, "上传中...")
|
|
144
|
-
end
|
|
120
|
+
private
|
|
145
121
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
project_name: @project_name || upload_params[:project_name]
|
|
150
|
-
)
|
|
122
|
+
# 在 upload_path 下查找 file_type 类型的最新文件
|
|
123
|
+
def find_latest_file_by_type
|
|
124
|
+
search_pattern = get_search_pattern_by_file_type
|
|
151
125
|
|
|
152
|
-
|
|
126
|
+
files = Dir.glob(search_pattern)
|
|
153
127
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
128
|
+
if files.any?
|
|
129
|
+
# 返回修改时间最新的文件
|
|
130
|
+
latest_file = files.max_by { |f| File.mtime(f) }
|
|
131
|
+
return latest_file
|
|
157
132
|
end
|
|
158
133
|
|
|
159
|
-
|
|
160
|
-
{
|
|
161
|
-
success: true,
|
|
162
|
-
platform: 'android',
|
|
163
|
-
file_path: @file_path,
|
|
164
|
-
upload_url: @upload_url
|
|
165
|
-
}
|
|
134
|
+
nil
|
|
166
135
|
end
|
|
167
136
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
137
|
+
# 根据 file_type 获取搜索模式
|
|
138
|
+
def get_search_pattern_by_file_type
|
|
139
|
+
case @file_type
|
|
140
|
+
when 'ipa'
|
|
141
|
+
File.join(@upload_path, "**", "*.ipa")
|
|
142
|
+
when 'apk'
|
|
143
|
+
File.join(@upload_path, "**", "*.apk")
|
|
144
|
+
when 'html'
|
|
145
|
+
File.join(@upload_path, "**", "*.html")
|
|
146
|
+
when 'app'
|
|
147
|
+
File.join(@upload_path, "**", "*.app")
|
|
175
148
|
else
|
|
176
|
-
|
|
177
|
-
update_progress(20, "文件大小: #{file_size.round(2)} MB")
|
|
149
|
+
raise "不支持的文件类型: #{@file_type}"
|
|
178
150
|
end
|
|
179
|
-
|
|
180
|
-
# 准备上传参数
|
|
181
|
-
upload_params = prepare_upload_params
|
|
182
|
-
|
|
183
|
-
update_progress(30, "开始上传到测试平台...")
|
|
184
|
-
|
|
185
|
-
# 执行上传
|
|
186
|
-
begin
|
|
187
|
-
# 模拟进度更新
|
|
188
|
-
upload_with_progress do |progress|
|
|
189
|
-
update_progress(30 + (progress * 0.6).to_i, "上传中...")
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# 实际上传逻辑(可能需要压缩文件夹)
|
|
193
|
-
if File.directory?(@file_path)
|
|
194
|
-
# 压缩文件夹
|
|
195
|
-
update_progress(40, "压缩 Web 文件...")
|
|
196
|
-
zip_path = compress_directory(@file_path)
|
|
197
|
-
|
|
198
|
-
result = @upload_helper.upload_web(
|
|
199
|
-
web_path: zip_path,
|
|
200
|
-
project_name: @project_name || upload_params[:project_name]
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
# 清理临时文件
|
|
204
|
-
File.delete(zip_path) if File.exist?(zip_path)
|
|
205
|
-
else
|
|
206
|
-
result = @upload_helper.upload_web(
|
|
207
|
-
web_path: @file_path,
|
|
208
|
-
project_name: @project_name || upload_params[:project_name]
|
|
209
|
-
)
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
@upload_url = result[:url] if result && result[:url]
|
|
213
|
-
|
|
214
|
-
update_progress(95, "处理上传结果...")
|
|
215
|
-
rescue => e
|
|
216
|
-
raise "HTML 上传失败: #{e.message}"
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
update_progress(100, "HTML 上传成功")
|
|
220
|
-
{
|
|
221
|
-
success: true,
|
|
222
|
-
platform: 'web',
|
|
223
|
-
file_path: @file_path,
|
|
224
|
-
upload_url: @upload_url
|
|
225
|
-
}
|
|
226
151
|
end
|
|
227
152
|
|
|
228
|
-
|
|
229
|
-
|
|
153
|
+
# 延迟获取 JPS 配置
|
|
154
|
+
def fetch_jps_config(file_path)
|
|
155
|
+
puts " 获取 JPS 配置..."
|
|
230
156
|
|
|
231
|
-
#
|
|
232
|
-
|
|
157
|
+
# 根据 file_type 确定 package_type
|
|
158
|
+
package_type = @file_type == 'html' ? 'zip' : @file_type
|
|
233
159
|
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
params[:build_number] = @context[:build_number]
|
|
237
|
-
params[:description] = @context[:description]
|
|
160
|
+
# 获取项目目录(从文件路径推断)
|
|
161
|
+
working_directory = @upload_path
|
|
238
162
|
|
|
239
|
-
|
|
240
|
-
|
|
163
|
+
# 调用 PgyerHelper 获取配置
|
|
164
|
+
@app_info_obj, @workflow_info = PgyerHelper.share_instace.prepare_upload(
|
|
165
|
+
working_directory: working_directory,
|
|
166
|
+
proj_name: @project_name,
|
|
167
|
+
package_type: package_type
|
|
168
|
+
)
|
|
241
169
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
# 实际实现中,应该根据上传 API 的进度回调来更新
|
|
245
|
-
10.times do |i|
|
|
246
|
-
sleep(0.2)
|
|
247
|
-
block.call(i / 10.0) if block_given?
|
|
170
|
+
unless @app_info_obj && @workflow_info
|
|
171
|
+
raise "无法获取 JPS 配置"
|
|
248
172
|
end
|
|
249
173
|
end
|
|
250
174
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
175
|
+
# 上传到 JPS 测试平台
|
|
176
|
+
def upload_to_jps(file_path)
|
|
177
|
+
pgyer_helper = PgyerHelper.share_instace
|
|
178
|
+
|
|
179
|
+
# 调用统一的上传接口
|
|
180
|
+
result_data = pgyer_helper.start_upload(
|
|
181
|
+
app_info_obj: @app_info_obj,
|
|
182
|
+
ipa_file_upload: file_path,
|
|
183
|
+
description: @context[:upload_desc], # 从 context 获取描述
|
|
184
|
+
workflow_info: @workflow_info
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# 解析上传结果
|
|
188
|
+
if result_data && result_data["data"] && result_data["data"]["id"]
|
|
189
|
+
app_version_info = result_data["data"]
|
|
190
|
+
|
|
191
|
+
# 打印应用版本信息
|
|
192
|
+
pgyer_helper.print_app_version_info(
|
|
193
|
+
app_info_obj: @app_info_obj,
|
|
194
|
+
app_version_info_obj: app_version_info
|
|
195
|
+
)
|
|
258
196
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
197
|
+
# 发送消息给自己
|
|
198
|
+
pgyer_helper.send_apptest_msg(
|
|
199
|
+
app_info_obj: @app_info_obj,
|
|
200
|
+
app_version_info_obj: app_version_info,
|
|
201
|
+
receiveType: "self"
|
|
202
|
+
)
|
|
262
203
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
204
|
+
# 如果需要发送到测试群
|
|
205
|
+
if @context[:send_to_chat]
|
|
206
|
+
pgyer_helper.send_apptest_msg(
|
|
207
|
+
app_info_obj: @app_info_obj,
|
|
208
|
+
app_version_info_obj: app_version_info,
|
|
209
|
+
chatEnv: "DevTest",
|
|
210
|
+
receiveType: "chat"
|
|
211
|
+
)
|
|
266
212
|
end
|
|
213
|
+
else
|
|
214
|
+
raise "上传失败:未获取到有效的返回数据"
|
|
267
215
|
end
|
|
268
|
-
|
|
269
|
-
zip_path
|
|
270
|
-
rescue LoadError
|
|
271
|
-
# 如果没有 zip gem,使用系统命令
|
|
272
|
-
zip_path = "#{dir_path}.zip"
|
|
273
|
-
system("zip -r '#{zip_path}' '#{dir_path}'")
|
|
274
|
-
zip_path
|
|
275
216
|
end
|
|
276
217
|
end
|
|
277
218
|
end
|
|
278
|
-
end
|
|
219
|
+
end
|