pindo 5.14.4 → 5.14.6
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/base/git_handler.rb +140 -65
- data/lib/pindo/client/httpclient.rb +88 -12
- data/lib/pindo/command/android/autobuild.rb +100 -32
- data/lib/pindo/command/appstore/bundleid.rb +1 -1
- data/lib/pindo/command/appstore/pem.rb +1 -1
- data/lib/pindo/command/ios/autobuild.rb +116 -56
- data/lib/pindo/command/jps/apptest.rb +129 -50
- data/lib/pindo/command/jps/bind.rb +284 -121
- data/lib/pindo/command/jps/media.rb +1 -15
- data/lib/pindo/command/jps/resign.rb +109 -99
- data/lib/pindo/command/jps/upload.rb +31 -4
- data/lib/pindo/command/jps.rb +0 -1
- data/lib/pindo/command/unity/autobuild.rb +100 -39
- data/lib/pindo/command/web/autobuild.rb +95 -27
- data/lib/pindo/command.rb +23 -15
- data/lib/pindo/module/pgyer/pgyerhelper.rb +181 -0
- data/lib/pindo/module/task/model/git/git_commit_task.rb +55 -4
- data/lib/pindo/module/task/model/git/git_tag_task.rb +5 -4
- data/lib/pindo/module/task/model/jps/jps_bind_package_task.rb +233 -0
- data/lib/pindo/module/task/model/jps/jps_message_task.rb +9 -6
- data/lib/pindo/module/task/model/jps/jps_resign_task.rb +20 -21
- data/lib/pindo/module/task/model/jps/jps_upload_media_task.rb +57 -22
- data/lib/pindo/module/task/model/jps/jps_upload_task.rb +4 -4
- data/lib/pindo/module/task/model/jps/jps_workflow_message_task.rb +190 -0
- data/lib/pindo/options/core/option_configuration.rb +4 -36
- data/lib/pindo/options/core/option_initializer.rb +6 -3
- data/lib/pindo/options/core/option_item.rb +0 -3
- data/lib/pindo/options/groups/jps_options.rb +30 -10
- data/lib/pindo/version.rb +1 -1
- metadata +12 -37
- data/lib/pindo/command/jps/comment.rb +0 -84
|
@@ -33,33 +33,55 @@ module Pindo
|
|
|
33
33
|
|
|
34
34
|
# 命令的详细说明,包含用法示例
|
|
35
35
|
self.description = <<-DESC
|
|
36
|
-
编译WebGL
|
|
36
|
+
编译WebGL包并支持上传到JPS测试平台。
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
参数优先级说明(从低到高):
|
|
39
|
+
|
|
40
|
+
1. 无参数:
|
|
41
|
+
- Git 提交 → 打 Git Tag → 编译 WebGL → 检查输出
|
|
42
|
+
|
|
43
|
+
2. --upload:
|
|
44
|
+
- 在基础流程上增加:上传 WebGL → 发送消息给自己
|
|
45
|
+
|
|
46
|
+
3. --media:
|
|
47
|
+
- 自动启用 --upload
|
|
48
|
+
- 在 --upload 基础上增加:上传媒体附件(JPSMedia/ 目录)
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
4. --bind:
|
|
51
|
+
- 自动启用 --media 和 --upload
|
|
52
|
+
- 在 --media 基础上增加:绑定 Git commit 到已上传的包
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
5. --send:
|
|
55
|
+
- 自动启用 --bind、--media 和 --upload
|
|
56
|
+
- 在 --bind 基础上增加:发送工作流消息到测试群
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
支持功能:
|
|
45
59
|
|
|
60
|
+
* 编译 Unity WebGL 包
|
|
61
|
+
* 上传到 JPS 测试平台
|
|
62
|
+
* 上传媒体附件(图片、视频)
|
|
63
|
+
* 绑定 Git commit 到已上传的包
|
|
64
|
+
* 发送测试通知(自己/测试群)
|
|
65
|
+
* 支持本地预览(使用 --run 参数)
|
|
46
66
|
* 支持并发任务执行(使用 --multi 参数)
|
|
47
67
|
|
|
48
68
|
使用示例:
|
|
49
69
|
|
|
50
|
-
$ pindo web autobuild
|
|
70
|
+
$ pindo web autobuild --proj="My App" # 指定项目名称
|
|
71
|
+
|
|
72
|
+
$ pindo web autobuild # 编译、打tag
|
|
51
73
|
|
|
52
|
-
$ pindo web autobuild --upload
|
|
74
|
+
$ pindo web autobuild --upload # 编译、打tag、上传、发上传消息
|
|
53
75
|
|
|
54
|
-
$ pindo web autobuild --
|
|
76
|
+
$ pindo web autobuild --media # 编译、打tag、上传、发上传消息、上传媒体附件
|
|
55
77
|
|
|
56
|
-
$ pindo web autobuild --
|
|
78
|
+
$ pindo web autobuild --bind # 编译、打tag、上传、发上传消息、上传媒体附件 + 绑定包到工作流
|
|
57
79
|
|
|
58
|
-
$ pindo web autobuild --
|
|
80
|
+
$ pindo web autobuild --send # 编译、打tag、上传、发上传消息、上传媒体附件、绑定包到工作流 + 发送群消息
|
|
59
81
|
|
|
60
|
-
$ pindo web autobuild --
|
|
82
|
+
$ pindo web autobuild --run # 编译完成后在本地打开 WebGL 包
|
|
61
83
|
|
|
62
|
-
$ pindo web autobuild --multi
|
|
84
|
+
$ pindo web autobuild --multi # 使用并发模式执行
|
|
63
85
|
DESC
|
|
64
86
|
|
|
65
87
|
# 命令的参数列表
|
|
@@ -70,6 +92,7 @@ module Pindo
|
|
|
70
92
|
# 定义此命令使用的参数项
|
|
71
93
|
def self.option_items
|
|
72
94
|
@option_items ||= Pindo::Options::OptionGroup.merge(
|
|
95
|
+
Pindo::Options::BuildOptions.select(:bundleid), # 添加 bundleid 参数
|
|
73
96
|
Pindo::Options::JPSOptions.select(:proj, :upload, :send, :media),
|
|
74
97
|
Pindo::Options::UnityOptions.select(:skiplib, :skipyoo),
|
|
75
98
|
Pindo::Options::UnityOptions.select_with_defaults(skipconfig: true),
|
|
@@ -81,7 +104,6 @@ module Pindo
|
|
|
81
104
|
# 命令的选项列表
|
|
82
105
|
def self.options
|
|
83
106
|
[
|
|
84
|
-
['--bundleid', '指定打包的bundleID'],
|
|
85
107
|
['--run', '编译完成后再本地打开webgl包']
|
|
86
108
|
].concat(option_items.map(&:to_claide_option)).concat(super)
|
|
87
109
|
end
|
|
@@ -91,12 +113,22 @@ module Pindo
|
|
|
91
113
|
|
|
92
114
|
@args_deploy_flag = argv.flag?('deploy', false)
|
|
93
115
|
@args_adhoc_flag = argv.flag?('adhoc', false)
|
|
94
|
-
@args_upload_flag = @options[:upload] || false
|
|
95
|
-
@args_send_flag = @options[:send] || false
|
|
96
|
-
@args_media_flag = @options[:media] || false
|
|
97
116
|
@args_proj_name = @options[:proj]
|
|
98
|
-
@args_bundle_id =
|
|
117
|
+
@args_bundle_id = @options[:bundleid] # 从 @options 获取,确保能被缓存
|
|
99
118
|
@args_run_flag = argv.flag?('run', false)
|
|
119
|
+
|
|
120
|
+
# send、media 或 bind 都依赖 upload:如果指定了任一参数,自动启用 upload
|
|
121
|
+
@args_upload_flag = @options[:send] || @options[:bind] || @options[:media] || @options[:upload]
|
|
122
|
+
|
|
123
|
+
# media 任务是独立的,不依赖任何其他任务,但是为输入命令参数更加简单,如果有--bind和--send, 则默认认为一定会有--media参数
|
|
124
|
+
@args_media_flag = @options[:send] || @options[:bind] || @options[:media] || false
|
|
125
|
+
|
|
126
|
+
# send 都依赖 bind:如果指定了任一参数,自动启用 bind
|
|
127
|
+
@args_bind_flag = @options[:send] || @options[:bind] || false
|
|
128
|
+
|
|
129
|
+
@args_send_flag = @options[:send]
|
|
130
|
+
|
|
131
|
+
# Unity 参数
|
|
100
132
|
@args_skip_lib = @options[:skiplib] || false
|
|
101
133
|
@args_skip_yoo = @options[:skipyoo] || false
|
|
102
134
|
|
|
@@ -109,10 +141,6 @@ module Pindo
|
|
|
109
141
|
@args_tag_type = Pindo::Options::GitOptions.parse_create_tag_type(@options[:tag_type] || 'new')
|
|
110
142
|
@args_tag_pre = @options[:tag_pre] || 'v'
|
|
111
143
|
|
|
112
|
-
if @args_send_flag || @args_media_flag
|
|
113
|
-
@args_upload_flag = true
|
|
114
|
-
end
|
|
115
|
-
|
|
116
144
|
super
|
|
117
145
|
@additional_args = argv.remainder!
|
|
118
146
|
end
|
|
@@ -292,8 +320,6 @@ module Pindo
|
|
|
292
320
|
options: {
|
|
293
321
|
project_path: config[:project_path],
|
|
294
322
|
proj_name: @args_proj_name,
|
|
295
|
-
upload: @args_upload_flag,
|
|
296
|
-
send: @args_send_flag,
|
|
297
323
|
app_info_obj: config[:app_info_obj],
|
|
298
324
|
workflow_info: config[:workflow_info]
|
|
299
325
|
}
|
|
@@ -302,6 +328,7 @@ module Pindo
|
|
|
302
328
|
tasks << build_task
|
|
303
329
|
|
|
304
330
|
# 7. 上传和消息发送任务(如果需要)
|
|
331
|
+
upload_task = nil # 声明变量以便后续绑定任务使用
|
|
305
332
|
if @args_upload_flag
|
|
306
333
|
# WebGL 输出路径: GoodPlatform/WebGL/build
|
|
307
334
|
webgl_build_path = File.join(config[:project_path], 'GoodPlatform', 'WebGL', 'build')
|
|
@@ -318,15 +345,15 @@ module Pindo
|
|
|
318
345
|
upload_task.dependencies << build_task.id
|
|
319
346
|
tasks << upload_task
|
|
320
347
|
|
|
321
|
-
# 7.2
|
|
348
|
+
# 7.2 创建消息发送任务(只依赖上传任务,固定发送给自己)
|
|
322
349
|
# app_version_info 将从 upload_task 的数据参数中获取
|
|
323
350
|
message_task = Pindo::TaskSystem::JPSMessageTask.new(
|
|
324
351
|
nil, # app_version_info 为 nil,从依赖任务获取
|
|
325
352
|
app_info_obj: config[:app_info_obj],
|
|
326
353
|
project_name: @args_proj_name,
|
|
327
|
-
send_message_type:
|
|
328
|
-
dependencies: [upload_task.id] # 从 upload_task 获取数据
|
|
354
|
+
send_message_type: 'self' # 固定发送给自己
|
|
329
355
|
)
|
|
356
|
+
message_task.dependencies << upload_task.id
|
|
330
357
|
tasks << message_task
|
|
331
358
|
end
|
|
332
359
|
|
|
@@ -347,11 +374,52 @@ module Pindo
|
|
|
347
374
|
workflow_info: git_workflow_info,
|
|
348
375
|
project_name: @args_proj_name
|
|
349
376
|
)
|
|
350
|
-
#
|
|
377
|
+
# 依赖 Git 提交任务
|
|
351
378
|
media_upload_task.dependencies << git_commit_task.id
|
|
352
379
|
tasks << media_upload_task
|
|
353
380
|
end
|
|
354
381
|
|
|
382
|
+
# 9. 创建 Git Commit 绑定任务(如果需要,依赖上传任务)
|
|
383
|
+
bind_package_task = nil # 声明变量以便后续工作流消息任务使用
|
|
384
|
+
if @args_bind_flag
|
|
385
|
+
bind_package_task = Pindo::TaskSystem::JPSBindPackageTask.new(
|
|
386
|
+
nil, # app_version_list 为 nil,从依赖任务获取
|
|
387
|
+
project_dir: config[:project_path],
|
|
388
|
+
app_info_obj: config[:app_info_obj],
|
|
389
|
+
workflow_info: config[:workflow_info],
|
|
390
|
+
project_name: @args_proj_name
|
|
391
|
+
)
|
|
392
|
+
# 依赖上传任务和 Git 提交任务
|
|
393
|
+
bind_package_task.dependencies << upload_task.id
|
|
394
|
+
bind_package_task.dependencies << git_commit_task.id
|
|
395
|
+
tasks << bind_package_task
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
# 10. 创建工作流消息任务(如果需要,发送到测试群)
|
|
399
|
+
if @args_send_flag
|
|
400
|
+
# 获取 Git 工作流信息
|
|
401
|
+
git_app_info_obj, git_workflow_info = PgyerHelper.share_instace.prepare_upload(
|
|
402
|
+
working_directory: config[:project_path],
|
|
403
|
+
proj_name: @args_proj_name,
|
|
404
|
+
package_type: "",
|
|
405
|
+
manage_type: "git"
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
workflow_message_task = Pindo::TaskSystem::JPSWorkFlowMessageTask.new(
|
|
409
|
+
project_id: git_app_info_obj["id"],
|
|
410
|
+
workflow_id: git_workflow_info["id"],
|
|
411
|
+
branch: 'master',
|
|
412
|
+
single: true,
|
|
413
|
+
app_info_obj: git_app_info_obj,
|
|
414
|
+
workflow_info: git_workflow_info
|
|
415
|
+
)
|
|
416
|
+
# 依赖 Git Commit、Git Tag 和 Bind Package 任务
|
|
417
|
+
workflow_message_task.dependencies << git_commit_task.id
|
|
418
|
+
workflow_message_task.dependencies << git_tag_task.id
|
|
419
|
+
workflow_message_task.dependencies << bind_package_task.id
|
|
420
|
+
tasks << workflow_message_task
|
|
421
|
+
end
|
|
422
|
+
|
|
355
423
|
tasks
|
|
356
424
|
else
|
|
357
425
|
raise Informative, "Web 编译只支持 Unity 工程"
|
data/lib/pindo/command.rb
CHANGED
|
@@ -11,7 +11,22 @@ require 'pindo/client/giteeclient'
|
|
|
11
11
|
require 'pindo/config/pindoconfig'
|
|
12
12
|
|
|
13
13
|
module Pindo
|
|
14
|
+
# Help 拦截器模块:统一处理 --help 参数
|
|
15
|
+
# 使用 prepend 确保在所有子类的 validate! 方法之前执行
|
|
16
|
+
module HelpValidator
|
|
17
|
+
def validate!
|
|
18
|
+
# 如果是 help 请求,调用 help! 并终止执行
|
|
19
|
+
# help! 会抛出 CLAide::Help 异常,阻止后续逻辑执行
|
|
20
|
+
help! if @args_help_flag
|
|
21
|
+
|
|
22
|
+
# 否则正常执行
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
14
27
|
class Command < CLAide::Command
|
|
28
|
+
# 使用 prepend 确保 HelpValidator 在所有子类之前执行
|
|
29
|
+
prepend HelpValidator
|
|
15
30
|
|
|
16
31
|
include Pindoconfig::Mixin
|
|
17
32
|
include Funlog::Mixin
|
|
@@ -105,30 +120,23 @@ module Pindo
|
|
|
105
120
|
end
|
|
106
121
|
end
|
|
107
122
|
|
|
108
|
-
def validate!
|
|
109
|
-
super
|
|
110
|
-
help! if args_help_flag?
|
|
111
|
-
end
|
|
112
|
-
|
|
113
123
|
def self.run(argv)
|
|
114
124
|
super(argv)
|
|
115
125
|
end
|
|
116
126
|
|
|
117
127
|
def initialize(argv)
|
|
118
128
|
super
|
|
119
|
-
@args_help_flag = argv.flag?('help', false)
|
|
120
|
-
@args_verbose_flag = argv.flag?('verbose', false)
|
|
121
129
|
|
|
122
|
-
# 检查是否是 help
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
# 检查是否是 help 请求
|
|
131
|
+
# CLAide 可能提前处理了 --help,所以我们需要检查原始参数
|
|
132
|
+
@args_help_flag = argv.flag?('help', false) ||
|
|
133
|
+
ARGV.include?('--help') ||
|
|
134
|
+
ARGV.include?('-h')
|
|
135
|
+
|
|
136
|
+
@args_verbose_flag = argv.flag?('verbose', false)
|
|
129
137
|
|
|
130
138
|
# 设置全局 verbose 标志
|
|
131
|
-
ENV['
|
|
139
|
+
ENV['PINDO_DEBUG'] = '1' if @args_verbose_flag
|
|
132
140
|
end
|
|
133
141
|
|
|
134
142
|
end
|
|
@@ -103,6 +103,7 @@ module Pindo
|
|
|
103
103
|
when 'apk' then 'apk_workflow'
|
|
104
104
|
when 'zip' then 'webgl_workflow'
|
|
105
105
|
when 'app' then 'macos_workflow'
|
|
106
|
+
when 'exe' then 'win_workflow'
|
|
106
107
|
else
|
|
107
108
|
puts "[JPSConfig] 不支持的 package_type: #{package_type}"
|
|
108
109
|
return result
|
|
@@ -1550,6 +1551,185 @@ module Pindo
|
|
|
1550
1551
|
end
|
|
1551
1552
|
end
|
|
1552
1553
|
|
|
1554
|
+
# 获取工作流中已绑定的包 ID
|
|
1555
|
+
#
|
|
1556
|
+
# @param workflow_id [Integer, String] 工作流 ID
|
|
1557
|
+
# @return [Array<String>] 已绑定的包 ID 数组
|
|
1558
|
+
def get_workflow_bound_package_ids(workflow_id:)
|
|
1559
|
+
return [] if workflow_id.nil?
|
|
1560
|
+
|
|
1561
|
+
begin
|
|
1562
|
+
# 调用 JPS API 获取工作流详情
|
|
1563
|
+
result = @pgyer_client.get_workflow_detail(workflowId: workflow_id)
|
|
1564
|
+
|
|
1565
|
+
# 兼容两种响应格式
|
|
1566
|
+
response_code = result&.dig("code") || result&.dig("meta", "code")
|
|
1567
|
+
|
|
1568
|
+
if result && (response_code == 0 || response_code == 200)
|
|
1569
|
+
# 从响应中提取 boundPackageIds
|
|
1570
|
+
workflow_data = result&.dig("data") || result&.dig("result")
|
|
1571
|
+
bound_ids = workflow_data&.dig("boundPackageIds") || []
|
|
1572
|
+
|
|
1573
|
+
# 确保返回数组(兼容字符串和数组)
|
|
1574
|
+
bound_ids = [bound_ids] unless bound_ids.is_a?(Array)
|
|
1575
|
+
|
|
1576
|
+
return bound_ids.compact
|
|
1577
|
+
else
|
|
1578
|
+
# 如果获取失败,返回空数组(不阻止绑定流程)
|
|
1579
|
+
if ENV['PINDO_DEBUG']
|
|
1580
|
+
error_msg = result&.dig("msg") || result&.dig("meta", "message") || "未知错误"
|
|
1581
|
+
puts "[PINDO_DEBUG] 获取工作流绑定包失败: #{error_msg}"
|
|
1582
|
+
end
|
|
1583
|
+
return []
|
|
1584
|
+
end
|
|
1585
|
+
rescue => e
|
|
1586
|
+
# 异常时返回空数组,不阻止绑定流程
|
|
1587
|
+
if ENV['PINDO_DEBUG']
|
|
1588
|
+
puts "[PINDO_DEBUG] 获取工作流绑定包异常: #{e.message}"
|
|
1589
|
+
end
|
|
1590
|
+
return []
|
|
1591
|
+
end
|
|
1592
|
+
end
|
|
1593
|
+
|
|
1594
|
+
# 获取工作流中最新的 commit id
|
|
1595
|
+
#
|
|
1596
|
+
# @param workflow_id [Integer, String] 工作流 ID
|
|
1597
|
+
# @return [String, nil] 最新的 commit id,失败时返回 nil
|
|
1598
|
+
def get_workflow_latest_commit_id(workflow_id:)
|
|
1599
|
+
return nil if workflow_id.nil?
|
|
1600
|
+
|
|
1601
|
+
begin
|
|
1602
|
+
# 调用 JPS API 获取工作流详情
|
|
1603
|
+
result = @pgyer_client.get_workflow_detail(workflowId: workflow_id)
|
|
1604
|
+
|
|
1605
|
+
# 兼容两种响应格式
|
|
1606
|
+
response_code = result&.dig("code") || result&.dig("meta", "code")
|
|
1607
|
+
|
|
1608
|
+
if result && (response_code == 0 || response_code == 200)
|
|
1609
|
+
# 从响应中提取工作流数据
|
|
1610
|
+
workflow_data = result&.dig("data") || result&.dig("result")
|
|
1611
|
+
|
|
1612
|
+
# 尝试从不同字段获取最新的 commit id
|
|
1613
|
+
# 1. 尝试从 latestCommitId 字段获取
|
|
1614
|
+
latest_commit = workflow_data&.dig("latestCommitId")
|
|
1615
|
+
|
|
1616
|
+
# 2. 如果没有 latestCommitId,尝试从 commits 数组获取第一个
|
|
1617
|
+
if latest_commit.nil? || latest_commit.empty?
|
|
1618
|
+
commits = workflow_data&.dig("commits") || []
|
|
1619
|
+
latest_commit = commits.first&.dig("id") || commits.first&.dig("commitId") if commits.any?
|
|
1620
|
+
end
|
|
1621
|
+
|
|
1622
|
+
# 3. 如果还是没有,尝试从 lastCommit 对象获取
|
|
1623
|
+
if latest_commit.nil? || latest_commit.empty?
|
|
1624
|
+
last_commit = workflow_data&.dig("lastCommit")
|
|
1625
|
+
latest_commit = last_commit&.dig("id") || last_commit&.dig("commitId")
|
|
1626
|
+
end
|
|
1627
|
+
|
|
1628
|
+
return latest_commit
|
|
1629
|
+
else
|
|
1630
|
+
# 如果获取失败,返回 nil
|
|
1631
|
+
if ENV['PINDO_DEBUG']
|
|
1632
|
+
error_msg = result&.dig("msg") || result&.dig("meta", "message") || "未知错误"
|
|
1633
|
+
puts "[PINDO_DEBUG] 获取工作流最新 commit id 失败: #{error_msg}"
|
|
1634
|
+
end
|
|
1635
|
+
return nil
|
|
1636
|
+
end
|
|
1637
|
+
rescue => e
|
|
1638
|
+
# 异常时返回 nil
|
|
1639
|
+
if ENV['PINDO_DEBUG']
|
|
1640
|
+
puts "[PINDO_DEBUG] 获取工作流最新 commit id 异常: #{e.message}"
|
|
1641
|
+
end
|
|
1642
|
+
return nil
|
|
1643
|
+
end
|
|
1644
|
+
end
|
|
1645
|
+
|
|
1646
|
+
# 绑定 Git commit 到项目包
|
|
1647
|
+
#
|
|
1648
|
+
# @param commit_id [String] Git commit SHA
|
|
1649
|
+
# @param project_package_ids [Array<String>] 项目包 ID 数组
|
|
1650
|
+
# @return [Hash] 绑定结果
|
|
1651
|
+
def bind_commit_to_package(commit_id:, project_package_ids:)
|
|
1652
|
+
if commit_id.nil? || commit_id.empty?
|
|
1653
|
+
Funlog.instance.fancyinfo_error("commit_id 不能为空")
|
|
1654
|
+
return { success: false, error: "commit_id 不能为空" }
|
|
1655
|
+
end
|
|
1656
|
+
|
|
1657
|
+
if project_package_ids.nil? || project_package_ids.empty?
|
|
1658
|
+
Funlog.instance.fancyinfo_error("project_package_ids 不能为空")
|
|
1659
|
+
return { success: false, error: "project_package_ids 不能为空" }
|
|
1660
|
+
end
|
|
1661
|
+
|
|
1662
|
+
begin
|
|
1663
|
+
result = @pgyer_client.bind_commit_to_package(
|
|
1664
|
+
commitId: commit_id,
|
|
1665
|
+
projectPackageIds: project_package_ids
|
|
1666
|
+
)
|
|
1667
|
+
|
|
1668
|
+
# 兼容两种响应格式
|
|
1669
|
+
response_code = result&.dig("code") || result&.dig("meta", "code")
|
|
1670
|
+
|
|
1671
|
+
if result && (response_code == 0 || response_code == 200)
|
|
1672
|
+
return { success: true, result: result }
|
|
1673
|
+
else
|
|
1674
|
+
error_msg = result&.dig("msg") || result&.dig("meta", "message") || result&.dig("message") || "未知错误"
|
|
1675
|
+
return { success: false, error: error_msg, result: result }
|
|
1676
|
+
end
|
|
1677
|
+
rescue => e
|
|
1678
|
+
Funlog.instance.fancyinfo_error("绑定失败: #{e.message}")
|
|
1679
|
+
return { success: false, error: e.message }
|
|
1680
|
+
end
|
|
1681
|
+
end
|
|
1682
|
+
|
|
1683
|
+
# 发送工作流消息(commit log 消息)
|
|
1684
|
+
#
|
|
1685
|
+
# @param project_id [String] 项目 ID
|
|
1686
|
+
# @param workflow_id [Integer] 工作流 ID
|
|
1687
|
+
# @param commit_id [String] Git commit SHA
|
|
1688
|
+
# @param branch [String] 分支名(可选,默认 'master')
|
|
1689
|
+
# @param single [Boolean] 是否单个提交(可选,默认 true)
|
|
1690
|
+
# @return [Hash] 发送结果
|
|
1691
|
+
def send_workflow_message(project_id:, workflow_id:, commit_id:, branch: 'master', single: true)
|
|
1692
|
+
if project_id.nil? || project_id.empty?
|
|
1693
|
+
Funlog.instance.fancyinfo_error("project_id 不能为空")
|
|
1694
|
+
return { success: false, error: "project_id 不能为空" }
|
|
1695
|
+
end
|
|
1696
|
+
|
|
1697
|
+
if workflow_id.nil?
|
|
1698
|
+
Funlog.instance.fancyinfo_error("workflow_id 不能为空")
|
|
1699
|
+
return { success: false, error: "workflow_id 不能为空" }
|
|
1700
|
+
end
|
|
1701
|
+
|
|
1702
|
+
if commit_id.nil? || commit_id.empty?
|
|
1703
|
+
Funlog.instance.fancyinfo_error("commit_id 不能为空")
|
|
1704
|
+
return { success: false, error: "commit_id 不能为空" }
|
|
1705
|
+
end
|
|
1706
|
+
|
|
1707
|
+
begin
|
|
1708
|
+
result = @pgyer_client.send_commit_log_message(
|
|
1709
|
+
projectId: project_id,
|
|
1710
|
+
workflowId: workflow_id,
|
|
1711
|
+
params: {
|
|
1712
|
+
single: single,
|
|
1713
|
+
branch: branch,
|
|
1714
|
+
commitIds: [commit_id]
|
|
1715
|
+
}
|
|
1716
|
+
)
|
|
1717
|
+
|
|
1718
|
+
# 兼容两种响应格式
|
|
1719
|
+
response_code = result&.dig("code") || result&.dig("meta", "code")
|
|
1720
|
+
|
|
1721
|
+
if result && (response_code == 0 || response_code == 200)
|
|
1722
|
+
return { success: true, result: result }
|
|
1723
|
+
else
|
|
1724
|
+
error_msg = result&.dig("msg") || result&.dig("meta", "message") || result&.dig("message") || "未知错误"
|
|
1725
|
+
return { success: false, error: error_msg, result: result }
|
|
1726
|
+
end
|
|
1727
|
+
rescue => e
|
|
1728
|
+
Funlog.instance.fancyinfo_error("发送工作流消息失败: #{e.message}")
|
|
1729
|
+
return { success: false, error: e.message }
|
|
1730
|
+
end
|
|
1731
|
+
end
|
|
1732
|
+
|
|
1553
1733
|
private
|
|
1554
1734
|
|
|
1555
1735
|
# 确定 JPSBuildConfig.json 文件路径
|
|
@@ -1634,6 +1814,7 @@ module Pindo
|
|
|
1634
1814
|
when 'apk' then 'apk_workflow'
|
|
1635
1815
|
when 'zip' then 'webgl_workflow'
|
|
1636
1816
|
when 'app' then 'macos_workflow'
|
|
1817
|
+
when 'exe' then 'win_workflow'
|
|
1637
1818
|
else raise Informative, "不支持的 package_type: #{package_type}"
|
|
1638
1819
|
end
|
|
1639
1820
|
end
|
|
@@ -110,13 +110,34 @@ module Pindo
|
|
|
110
110
|
raise e
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
# 4.
|
|
113
|
+
# 4. Stash 工作目录的残留修改(为分支同步做准备)
|
|
114
|
+
stash_saved = false
|
|
115
|
+
status = Pindo::GitHandler.git!(%W(-C #{root_dir} status --porcelain)).strip
|
|
116
|
+
unless status.empty?
|
|
117
|
+
Funlog.instance.fancyinfo_update("工作目录有未提交更改,暂存到 stash")
|
|
118
|
+
Pindo::GitHandler.git!(%W(-C #{root_dir} stash -u))
|
|
119
|
+
stash_saved = true
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# 5. 获取当前分支
|
|
114
123
|
coding_branch = get_current_branch_name
|
|
115
124
|
|
|
116
|
-
#
|
|
125
|
+
# 6. 检查并推送本地提交到远程(确保本地和远程同步)
|
|
117
126
|
Pindo::GitHandler.check_unpushed_commits(project_dir: root_dir, branch: coding_branch)
|
|
118
127
|
|
|
119
|
-
#
|
|
128
|
+
# 7. 分支同步:将 coding_branch 和 release_branch 双向合并(确保两分支在同一节点)
|
|
129
|
+
if coding_branch != @release_branch
|
|
130
|
+
Funlog.instance.fancyinfo_start("开始同步 #{coding_branch} 和 #{@release_branch} 分支")
|
|
131
|
+
Pindo::GitHandler.merge_branches(
|
|
132
|
+
project_dir: root_dir,
|
|
133
|
+
source_branch: coding_branch,
|
|
134
|
+
target_branch: @release_branch,
|
|
135
|
+
sync_branches: true # 双向合并,确保两分支完全同步
|
|
136
|
+
)
|
|
137
|
+
Funlog.instance.fancyinfo_success("分支同步完成,#{coding_branch} 和 #{@release_branch} 现在在同一节点")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# 8. 计算 build_version
|
|
120
141
|
# 优先级 1: 如果指定了 fixed_version(外部传入或从 HEAD tag 获取),使用它
|
|
121
142
|
if @fixed_version && !@fixed_version.empty?
|
|
122
143
|
@build_version = @fixed_version
|
|
@@ -135,6 +156,18 @@ module Pindo
|
|
|
135
156
|
Funlog.instance.fancyinfo_success("计算新版本号: #{@build_version}, Build: #{@build_number}")
|
|
136
157
|
end
|
|
137
158
|
|
|
159
|
+
# 9. 还原 stash(如果之前有 stash)
|
|
160
|
+
if stash_saved
|
|
161
|
+
begin
|
|
162
|
+
Pindo::GitHandler.git!(%W(-C #{root_dir} stash pop))
|
|
163
|
+
Funlog.instance.fancyinfo_success("已还原 stash")
|
|
164
|
+
rescue => e
|
|
165
|
+
Funlog.instance.fancyinfo_warning("stash 还原时发生冲突: #{e.message}")
|
|
166
|
+
Funlog.instance.fancyinfo_warning("stash 已保留,请手动执行 'git stash pop' 处理冲突")
|
|
167
|
+
# 不抛出异常,任务继续(版本号已计算成功,stash 冲突不影响构建)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
138
171
|
{
|
|
139
172
|
success: true,
|
|
140
173
|
root_dir: root_dir,
|
|
@@ -150,7 +183,7 @@ module Pindo
|
|
|
150
183
|
# 如果不是 Git 仓库,返回空参数(让依赖任务知道没有有效数据)
|
|
151
184
|
return {} if @build_version.nil? || @build_number.nil?
|
|
152
185
|
|
|
153
|
-
{
|
|
186
|
+
param = {
|
|
154
187
|
release_branch: @release_branch,
|
|
155
188
|
build_version: @build_version,
|
|
156
189
|
build_number: @build_number,
|
|
@@ -158,6 +191,24 @@ module Pindo
|
|
|
158
191
|
tag_type: @tag_type,
|
|
159
192
|
ver_inc: @ver_inc
|
|
160
193
|
}
|
|
194
|
+
|
|
195
|
+
# 添加 git commit 信息(供 JPSUploadMediaTask 等任务使用)
|
|
196
|
+
if @git_root_path
|
|
197
|
+
begin
|
|
198
|
+
# 获取当前 HEAD commit 信息
|
|
199
|
+
git_commit_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: @git_root_path)
|
|
200
|
+
if git_commit_info
|
|
201
|
+
param[:git_commit_id] = git_commit_info[:commit_id]
|
|
202
|
+
param[:git_commit_time] = git_commit_info[:commit_time]
|
|
203
|
+
param[:git_commit_desc] = git_commit_info[:commit_desc]
|
|
204
|
+
end
|
|
205
|
+
rescue => e
|
|
206
|
+
# 如果获取失败,不影响主流程
|
|
207
|
+
Funlog.instance.fancyinfo_warning("获取 git commit 信息失败: #{e.message}") if ENV['PINDO_DEBUG']
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
param
|
|
161
212
|
end
|
|
162
213
|
end
|
|
163
214
|
end
|
|
@@ -73,12 +73,13 @@ module Pindo
|
|
|
73
73
|
stash_saved = true
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# 2.
|
|
76
|
+
# 2. 合并到发布分支(双向同步,确保 coding_branch 和 release_branch 保持一致)
|
|
77
77
|
if coding_branch != @release_branch
|
|
78
|
-
Pindo::GitHandler.
|
|
78
|
+
Pindo::GitHandler.merge_branches(
|
|
79
79
|
project_dir: root_dir,
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
source_branch: coding_branch,
|
|
81
|
+
target_branch: @release_branch,
|
|
82
|
+
sync_branches: true # 双向合并,确保两分支完全同步
|
|
82
83
|
)
|
|
83
84
|
end
|
|
84
85
|
|