pindo 5.14.4 → 5.14.5

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.
@@ -1550,6 +1550,93 @@ module Pindo
1550
1550
  end
1551
1551
  end
1552
1552
 
1553
+ # 绑定 Git commit 到项目包
1554
+ #
1555
+ # @param commit_id [String] Git commit SHA
1556
+ # @param project_package_ids [Array<String>] 项目包 ID 数组
1557
+ # @return [Hash] 绑定结果
1558
+ def bind_commit_to_package(commit_id:, project_package_ids:)
1559
+ if commit_id.nil? || commit_id.empty?
1560
+ Funlog.instance.fancyinfo_error("commit_id 不能为空")
1561
+ return { success: false, error: "commit_id 不能为空" }
1562
+ end
1563
+
1564
+ if project_package_ids.nil? || project_package_ids.empty?
1565
+ Funlog.instance.fancyinfo_error("project_package_ids 不能为空")
1566
+ return { success: false, error: "project_package_ids 不能为空" }
1567
+ end
1568
+
1569
+ begin
1570
+ result = @pgyer_client.bind_commit_to_package(
1571
+ commitId: commit_id,
1572
+ projectPackageIds: project_package_ids
1573
+ )
1574
+
1575
+ # 兼容两种响应格式
1576
+ response_code = result&.dig("code") || result&.dig("meta", "code")
1577
+
1578
+ if result && (response_code == 0 || response_code == 200)
1579
+ return { success: true, result: result }
1580
+ else
1581
+ error_msg = result&.dig("msg") || result&.dig("meta", "message") || result&.dig("message") || "未知错误"
1582
+ return { success: false, error: error_msg, result: result }
1583
+ end
1584
+ rescue => e
1585
+ Funlog.instance.fancyinfo_error("绑定失败: #{e.message}")
1586
+ return { success: false, error: e.message }
1587
+ end
1588
+ end
1589
+
1590
+ # 发送工作流消息(commit log 消息)
1591
+ #
1592
+ # @param project_id [String] 项目 ID
1593
+ # @param workflow_id [Integer] 工作流 ID
1594
+ # @param commit_id [String] Git commit SHA
1595
+ # @param branch [String] 分支名(可选,默认 'master')
1596
+ # @param single [Boolean] 是否单个提交(可选,默认 true)
1597
+ # @return [Hash] 发送结果
1598
+ def send_workflow_message(project_id:, workflow_id:, commit_id:, branch: 'master', single: true)
1599
+ if project_id.nil? || project_id.empty?
1600
+ Funlog.instance.fancyinfo_error("project_id 不能为空")
1601
+ return { success: false, error: "project_id 不能为空" }
1602
+ end
1603
+
1604
+ if workflow_id.nil?
1605
+ Funlog.instance.fancyinfo_error("workflow_id 不能为空")
1606
+ return { success: false, error: "workflow_id 不能为空" }
1607
+ end
1608
+
1609
+ if commit_id.nil? || commit_id.empty?
1610
+ Funlog.instance.fancyinfo_error("commit_id 不能为空")
1611
+ return { success: false, error: "commit_id 不能为空" }
1612
+ end
1613
+
1614
+ begin
1615
+ result = @pgyer_client.send_commit_log_message(
1616
+ projectId: project_id,
1617
+ workflowId: workflow_id,
1618
+ params: {
1619
+ single: single,
1620
+ branch: branch,
1621
+ commitIds: [commit_id]
1622
+ }
1623
+ )
1624
+
1625
+ # 兼容两种响应格式
1626
+ response_code = result&.dig("code") || result&.dig("meta", "code")
1627
+
1628
+ if result && (response_code == 0 || response_code == 200)
1629
+ return { success: true, result: result }
1630
+ else
1631
+ error_msg = result&.dig("msg") || result&.dig("meta", "message") || result&.dig("message") || "未知错误"
1632
+ return { success: false, error: error_msg, result: result }
1633
+ end
1634
+ rescue => e
1635
+ Funlog.instance.fancyinfo_error("发送工作流消息失败: #{e.message}")
1636
+ return { success: false, error: e.message }
1637
+ end
1638
+ end
1639
+
1553
1640
  private
1554
1641
 
1555
1642
  # 确定 JPSBuildConfig.json 文件路径
@@ -150,7 +150,7 @@ module Pindo
150
150
  # 如果不是 Git 仓库,返回空参数(让依赖任务知道没有有效数据)
151
151
  return {} if @build_version.nil? || @build_number.nil?
152
152
 
153
- {
153
+ param = {
154
154
  release_branch: @release_branch,
155
155
  build_version: @build_version,
156
156
  build_number: @build_number,
@@ -158,6 +158,24 @@ module Pindo
158
158
  tag_type: @tag_type,
159
159
  ver_inc: @ver_inc
160
160
  }
161
+
162
+ # 添加 git commit 信息(供 JPSUploadMediaTask 等任务使用)
163
+ if @git_root_path
164
+ begin
165
+ # 获取当前 HEAD commit 信息
166
+ git_commit_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: @git_root_path)
167
+ if git_commit_info
168
+ param[:git_commit_id] = git_commit_info[:commit_id]
169
+ param[:git_commit_time] = git_commit_info[:commit_time]
170
+ param[:git_commit_desc] = git_commit_info[:commit_desc]
171
+ end
172
+ rescue => e
173
+ # 如果获取失败,不影响主流程
174
+ Funlog.instance.fancyinfo_warning("获取 git commit 信息失败: #{e.message}") if ENV['PINDO_DEBUG']
175
+ end
176
+ end
177
+
178
+ param
161
179
  end
162
180
  end
163
181
  end
@@ -0,0 +1,217 @@
1
+ require 'pindo/module/task/model/jps_task'
2
+ require 'pindo/module/task/task_config'
3
+ require 'pindo/module/pgyer/pgyerhelper'
4
+ require 'pindo/base/git_handler'
5
+
6
+ module Pindo
7
+ module TaskSystem
8
+ # JPS 绑定包任务
9
+ # 将 Git commit 绑定到已上传的项目包(支持批量绑定)
10
+ #
11
+ # 支持两种模式:
12
+ # 1. 指定模式:传入 git_commit_id 和 app_version_list
13
+ # 2. 依赖模式:从依赖任务(GitCommitTask、JPSUploadTask)获取信息
14
+ class JPSBindPackageTask < JPSTask
15
+ attr_reader :git_commit_id, :git_commit_time, :git_commit_desc
16
+ attr_reader :app_version_list
17
+
18
+ # 任务键
19
+ def self.task_key
20
+ :jps_bind_package
21
+ end
22
+
23
+ # 初始化绑定包任务
24
+ # @param app_version_list [Array<Hash>, nil] 应用版本信息列表(可选,如为 nil 则从依赖任务获取)
25
+ # @param options [Hash] 选项
26
+ # @option options [String] :git_commit_id Git commit SHA(可选,为空时从依赖任务获取)
27
+ # @option options [String] :git_commit_time Git commit 时间(可选)
28
+ # @option options [String] :git_commit_desc Git commit 描述(可选)
29
+ # @option options [String] :project_dir 项目目录(可选,用于自动获取 commit 信息)
30
+ # @option options [Hash] :app_info_obj JPS 应用信息对象(可选,继承自基类)
31
+ # @option options [Hash] :workflow_info 工作流信息(可选,继承自基类)
32
+ # @option options [String] :project_name 项目名称(可选,继承自基类)
33
+ def initialize(app_version_list = nil, options = {})
34
+ # 兼容性处理:如果传入的是单个 Hash,转为数组
35
+ if app_version_list.is_a?(Hash)
36
+ @app_version_list = [app_version_list]
37
+ elsif app_version_list.is_a?(Array)
38
+ @app_version_list = app_version_list
39
+ else
40
+ @app_version_list = nil
41
+ end
42
+
43
+ @git_commit_id = options[:git_commit_id]
44
+ @git_commit_time = options[:git_commit_time]
45
+ @git_commit_desc = options[:git_commit_desc]
46
+ @project_dir = options[:project_dir]
47
+
48
+ # 设置任务优先级为 LOW,确保在上传任务之后执行
49
+ options[:priority] ||= TaskPriority::LOW
50
+
51
+ super("绑定 Git Commit 到项目包", options)
52
+ end
53
+
54
+ def validate
55
+ # app_version_list 和 git_commit_id 可以延迟获取,不在这里验证
56
+ true
57
+ end
58
+
59
+ # 绑定任务重试配置
60
+ def self.default_retry_mode
61
+ RetryMode::DELAYED
62
+ end
63
+
64
+ def self.default_retry_count
65
+ 2 # 绑定任务重试 2 次
66
+ end
67
+
68
+ def self.default_retry_delay
69
+ 3 # 延迟 3 秒
70
+ end
71
+
72
+ protected
73
+
74
+ # 构建任务参数(供其他任务使用)
75
+ def build_task_param
76
+ return {} unless @status == TaskStatus::SUCCESS && @result
77
+
78
+ {
79
+ git_commit_id: @git_commit_id,
80
+ app_version_list: @app_version_list,
81
+ bind_success: @result[:success],
82
+ bound_package_ids: @result[:bound_package_ids]
83
+ }
84
+ end
85
+
86
+ def do_work
87
+ puts ""
88
+ puts " 📦 开始绑定 Git Commit 到项目包..."
89
+
90
+ # 1. 如果没有提供 app_version_list,从依赖任务获取
91
+ if @app_version_list.nil? || @app_version_list.empty?
92
+ fetch_app_version_from_dependencies
93
+ end
94
+
95
+ # 验证 app_version_list
96
+ if @app_version_list.nil? || @app_version_list.empty?
97
+ raise "无法获取 app_version_list,请确保传入参数或添加 JPSUploadTask 依赖"
98
+ end
99
+
100
+ # 2. 如果没有提供 git_commit_id,从依赖任务获取或自动获取
101
+ if @git_commit_id.nil? || @git_commit_id.empty?
102
+ fetch_git_commit_info
103
+ end
104
+
105
+ # 验证 git_commit_id
106
+ if @git_commit_id.nil? || @git_commit_id.empty?
107
+ raise "无法获取 git_commit_id,请确保传入参数或添加 GitCommitTask 依赖"
108
+ end
109
+
110
+ # 3. 提取所有 project_package_ids
111
+ project_package_ids = @app_version_list.map { |pkg| pkg["id"] }.compact
112
+ if project_package_ids.empty?
113
+ raise "app_version_list 中的包都缺少 id 字段"
114
+ end
115
+
116
+ # 4. 打印绑定信息
117
+ puts ""
118
+ puts " 📝 绑定信息:"
119
+ puts " Git Commit: #{@git_commit_id[0..7]}"
120
+ puts " 包数量: #{project_package_ids.size} 个"
121
+ @app_version_list.each do |pkg|
122
+ package_type = pkg['nativePackageType'] || pkg['originalType'] || 'unknown'
123
+ puts " [#{package_type}] ID: #{pkg['id']}, Version: #{pkg['projectVersion']}, Build: #{pkg['build']}"
124
+ end
125
+ if @git_commit_desc
126
+ puts " Commit Desc: #{@git_commit_desc}"
127
+ end
128
+ if @git_commit_time
129
+ puts " Commit Time: #{@git_commit_time}"
130
+ end
131
+ puts ""
132
+
133
+ # 5. 确保 PgyerHelper 已登录
134
+ pgyer_helper = PgyerHelper.share_instace
135
+ unless pgyer_helper.login
136
+ raise "无法登录 JPS,请检查配置"
137
+ end
138
+
139
+ # 6. 批量绑定所有包
140
+ Funlog.instance.fancyinfo_start("正在绑定 #{project_package_ids.size} 个项目包...")
141
+
142
+ bind_result = pgyer_helper.bind_commit_to_package(
143
+ commit_id: @git_commit_id,
144
+ project_package_ids: project_package_ids
145
+ )
146
+
147
+ if bind_result[:success]
148
+ Funlog.instance.fancyinfo_success("绑定成功!")
149
+ puts ""
150
+
151
+ {
152
+ success: true,
153
+ git_commit_id: @git_commit_id,
154
+ bound_package_ids: project_package_ids,
155
+ app_version_list: @app_version_list
156
+ }
157
+ else
158
+ if ENV['PINDO_DEBUG']
159
+ puts "[PINDO_DEBUG] bind_commit_to_package 返回结果: #{bind_result.inspect}"
160
+ puts "[PINDO_DEBUG] git_commit_id: #{@git_commit_id}"
161
+ puts "[PINDO_DEBUG] project_package_ids: #{project_package_ids.inspect}"
162
+ end
163
+
164
+ raise "绑定失败: #{bind_result[:error]}"
165
+ end
166
+ end
167
+
168
+ private
169
+
170
+ # 从依赖任务获取 app_version_list
171
+ def fetch_app_version_from_dependencies
172
+ # 从 JPSUploadTask 获取数据
173
+ upload_data = get_data_param_by_key(:jps_upload)
174
+
175
+ if upload_data && upload_data[:task_param] && upload_data[:task_param][:app_version_info]
176
+ # 兼容单个版本信息,转为数组
177
+ @app_version_list = [upload_data[:task_param][:app_version_info]]
178
+ return
179
+ end
180
+
181
+ # 兼容旧机制:从第一个依赖获取结果
182
+ unless @dependencies.empty?
183
+ upload_result = get_dependency_result(@dependencies.first)
184
+
185
+ if upload_result && upload_result[:app_version_info]
186
+ # 兼容单个版本信息,转为数组
187
+ @app_version_list = [upload_result[:app_version_info]]
188
+ end
189
+ end
190
+ end
191
+
192
+ # 从依赖任务获取或自动获取 git commit 信息
193
+ def fetch_git_commit_info
194
+ # 1. 首先尝试从 GitCommitTask 依赖任务获取
195
+ git_commit_data = get_data_param_by_key(:git_commit)
196
+ if git_commit_data && git_commit_data[:task_param]
197
+ param = git_commit_data[:task_param]
198
+ @git_commit_id = param[:git_commit_id] if param[:git_commit_id]
199
+ @git_commit_time = param[:git_commit_time] if param[:git_commit_time]
200
+ @git_commit_desc = param[:git_commit_desc] if param[:git_commit_desc]
201
+ end
202
+
203
+ # 2. 如果依赖任务没有提供,且指定了 project_dir,使用自动获取
204
+ if (@git_commit_id.nil? || @git_commit_id.empty?) && @project_dir
205
+ # 查找 git 仓库根目录
206
+ git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: @project_dir)
207
+ if git_root
208
+ git_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: git_root)
209
+ @git_commit_id = git_info[:commit_id]
210
+ @git_commit_time = git_info[:commit_time]
211
+ @git_commit_desc = git_info[:commit_desc]
212
+ end
213
+ end
214
+ end
215
+ end
216
+ end
217
+ end
@@ -90,17 +90,30 @@ module Pindo
90
90
 
91
91
  def do_work
92
92
  # 1. 查找 git 仓库根目录
93
- git_root = find_git_root(@upload_path)
93
+ git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: @upload_path)
94
94
  unless git_root
95
95
  raise "未找到 git 仓库,请确保 upload_path 在 git 仓库内"
96
96
  end
97
97
 
98
- # 2. 如果没有提供 git_commit_id,获取最新的符合规范的 commit
98
+ # 2. 如果没有提供 git_commit_id,尝试从依赖任务获取或自动获取
99
99
  if @git_commit_id.nil? || @git_commit_id.empty?
100
- git_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: git_root)
101
- @git_commit_id = git_info[:commit_id]
102
- @git_commit_time = git_info[:commit_time]
103
- @git_commit_desc = git_info[:commit_desc]
100
+ # 2.1 首先尝试从 GitCommitTask 依赖任务获取
101
+ git_commit_data = get_data_param_by_key(:git_commit)
102
+ if git_commit_data && git_commit_data[:task_param]
103
+ param = git_commit_data[:task_param]
104
+ # 尝试从 task_param 获取 commit 信息
105
+ @git_commit_id = param[:git_commit_id] if param[:git_commit_id]
106
+ @git_commit_time = param[:git_commit_time] if param[:git_commit_time]
107
+ @git_commit_desc = param[:git_commit_desc] if param[:git_commit_desc]
108
+ end
109
+
110
+ # 2.2 如果依赖任务没有提供,使用 get_latest_conventional_commit
111
+ if @git_commit_id.nil? || @git_commit_id.empty?
112
+ git_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: git_root)
113
+ @git_commit_id = git_info[:commit_id]
114
+ @git_commit_time = git_info[:commit_time]
115
+ @git_commit_desc = git_info[:commit_desc]
116
+ end
104
117
  end
105
118
 
106
119
  # 验证 git_commit_id
@@ -110,8 +123,8 @@ module Pindo
110
123
 
111
124
  # 3. 打印 git commit 信息
112
125
  puts ""
113
- puts " 📝 Commit: #{@git_commit_desc}" if @git_commit_desc
114
126
  puts " ID: #{@git_commit_id[0..7]}"
127
+ puts " 📝 Commit: #{@git_commit_desc}" if @git_commit_desc
115
128
  puts " Time: #{@git_commit_time}" if @git_commit_time
116
129
  puts ""
117
130
 
@@ -192,20 +205,6 @@ module Pindo
192
205
 
193
206
  private
194
207
 
195
- # 查找 git 仓库根目录
196
- # @param path [String] 起始路径
197
- # @return [String, nil] git 仓库根目录路径,未找到返回 nil
198
- def find_git_root(path)
199
- current = File.expand_path(path)
200
- while current != '/'
201
- if File.exist?(File.join(current, '.git'))
202
- return current
203
- end
204
- current = File.dirname(current)
205
- end
206
- nil
207
- end
208
-
209
208
  # 展开文件路径(支持通配符和目录)
210
209
  # 自动过滤 3 小时以内的文件,超过 3 小时的文件归档
211
210
  # @param paths [Array<String>] 原始路径列表
@@ -0,0 +1,190 @@
1
+ require 'pindo/module/task/model/jps_task'
2
+ require 'pindo/module/task/task_config'
3
+ require 'pindo/module/pgyer/pgyerhelper'
4
+
5
+ module Pindo
6
+ module TaskSystem
7
+ # JPS 工作流消息发送任务
8
+ # 使用 commit_log/send_message 接口发送 Git commit 消息到工作流
9
+ class JPSWorkFlowMessageTask < JPSTask
10
+ attr_reader :git_commit_id, :git_commit_time, :git_commit_desc
11
+ attr_reader :project_id, :workflow_id, :branch
12
+
13
+ # 任务键
14
+ def self.task_key
15
+ :jps_workflow_message
16
+ end
17
+
18
+ # 初始化工作流消息发送任务
19
+ # @param options [Hash] 选项
20
+ # @option options [String] :git_commit_id Git commit SHA(可选,从依赖任务获取)
21
+ # @option options [String] :git_commit_time Git commit 时间(可选)
22
+ # @option options [String] :git_commit_desc Git commit 描述(可选)
23
+ # @option options [String] :project_id 项目 ID(可选,从 app_info_obj 获取)
24
+ # @option options [Integer] :workflow_id 工作流 ID(可选,从 workflow_info 获取)
25
+ # @option options [String] :branch 分支名(可选,默认 'master')
26
+ # @option options [Boolean] :single 是否单个提交(默认 true)
27
+ # @option options [Hash] :app_info_obj JPS 应用信息对象(可选,用于获取 project_id)
28
+ # @option options [Hash] :workflow_info 工作流信息(可选,用于获取 workflow_id)
29
+ def initialize(options = {})
30
+ @git_commit_id = options[:git_commit_id]
31
+ @git_commit_time = options[:git_commit_time]
32
+ @git_commit_desc = options[:git_commit_desc]
33
+ @project_id = options[:project_id]
34
+ @workflow_id = options[:workflow_id]
35
+ @branch = options[:branch] || 'master'
36
+ @single = options.fetch(:single, true)
37
+
38
+ # 消息发送任务优先级为 LOW,确保在其他任务之后执行
39
+ options[:priority] ||= TaskPriority::LOW
40
+
41
+ super("JPS 工作流消息发送", options)
42
+ end
43
+
44
+ def validate
45
+ # 参数可以从依赖任务获取,这里不做严格验证
46
+ true
47
+ end
48
+
49
+ protected
50
+
51
+ def do_work
52
+ puts "\n 📋 开始发送 JPS 工作流消息..."
53
+
54
+ begin
55
+ # 1. 如果没有提供参数,从依赖任务获取
56
+ fetch_data_from_dependencies if need_fetch_dependencies?
57
+
58
+ # 2. 验证必需参数
59
+ validate_required_params!
60
+
61
+ # 3. 发送消息
62
+ send_workflow_message
63
+
64
+ puts " ✅ JPS 工作流消息发送完成\n"
65
+
66
+ {
67
+ success: true,
68
+ git_commit_id: @git_commit_id,
69
+ project_id: @project_id,
70
+ workflow_id: @workflow_id
71
+ }
72
+ rescue => e
73
+ # 外层错误保护:消息发送失败不应影响整体流程
74
+ puts " ⚠️ JPS 工作流消息发送发生错误: #{e.message}"
75
+ puts " ⚠️ 错误堆栈: #{e.backtrace.first(3).join("\n ")}" if ENV['PINDO_DEBUG'] && e.backtrace
76
+ puts " ℹ️ 消息发送失败不影响主流程\n"
77
+
78
+ # 消息发送失败不抛出异常,返回成功但带警告
79
+ {
80
+ success: true,
81
+ warning: e.message,
82
+ git_commit_id: @git_commit_id
83
+ }
84
+ end
85
+ end
86
+
87
+ private
88
+
89
+ # 判断是否需要从依赖任务获取数据
90
+ def need_fetch_dependencies?
91
+ @git_commit_id.nil? || @project_id.nil? || @workflow_id.nil?
92
+ end
93
+
94
+ # 从依赖任务获取数据
95
+ def fetch_data_from_dependencies
96
+ # 1. 从 GitCommitTask 获取 commit 信息
97
+ if @git_commit_id.nil?
98
+ git_commit_data = get_data_param_by_key(:git_commit)
99
+ if git_commit_data && git_commit_data[:task_param]
100
+ param = git_commit_data[:task_param]
101
+ @git_commit_id = param[:git_commit_id] if param[:git_commit_id]
102
+ @git_commit_time = param[:git_commit_time] if param[:git_commit_time]
103
+ @git_commit_desc = param[:git_commit_desc] if param[:git_commit_desc]
104
+ end
105
+ end
106
+
107
+ # 2. 从 JPSUploadTask 获取 project_id 和 workflow_id
108
+ if @project_id.nil? || @workflow_id.nil?
109
+ upload_data = get_data_param_by_key(:jps_upload)
110
+ if upload_data && upload_data[:task_param]
111
+ param = upload_data[:task_param]
112
+
113
+ # 从 app_info_obj 获取 project_id
114
+ if @project_id.nil? && param[:app_info_obj]
115
+ @project_id = param[:app_info_obj]["id"] || param[:app_info_obj][:id]
116
+ end
117
+
118
+ # 从 workflow_info 获取 workflow_id
119
+ if @workflow_id.nil? && param[:workflow_info]
120
+ @workflow_id = param[:workflow_info]["id"] ||
121
+ param[:workflow_info][:id] ||
122
+ param[:workflow_info]["workflow_id"] ||
123
+ param[:workflow_info][:workflow_id]
124
+ end
125
+ end
126
+ end
127
+
128
+ # 3. 如果还没有,尝试从 app_info_obj 和 workflow_info(基类属性)获取
129
+ if @project_id.nil? && @app_info_obj
130
+ @project_id = @app_info_obj["id"] || @app_info_obj[:id]
131
+ end
132
+
133
+ if @workflow_id.nil? && @workflow_info
134
+ @workflow_id = @workflow_info["id"] ||
135
+ @workflow_info[:id] ||
136
+ @workflow_info["workflow_id"] ||
137
+ @workflow_info[:workflow_id]
138
+ end
139
+ end
140
+
141
+ # 验证必需参数
142
+ def validate_required_params!
143
+ missing_params = []
144
+ missing_params << "git_commit_id" if @git_commit_id.nil? || @git_commit_id.empty?
145
+ missing_params << "project_id" if @project_id.nil? || @project_id.empty?
146
+ missing_params << "workflow_id" if @workflow_id.nil?
147
+
148
+ unless missing_params.empty?
149
+ raise "缺少必需参数: #{missing_params.join(', ')}"
150
+ end
151
+ end
152
+
153
+ # 发送工作流消息
154
+ def send_workflow_message
155
+ puts " 📨 发送工作流消息..."
156
+ puts " Project ID: #{@project_id}"
157
+ puts " Workflow ID: #{@workflow_id}"
158
+ puts " Commit ID: #{@git_commit_id[0..7]}" if @git_commit_id
159
+ puts " Branch: #{@branch}"
160
+ puts ""
161
+
162
+ pgyer_helper = PgyerHelper.share_instace
163
+
164
+ # 确保已登录
165
+ unless pgyer_helper.login
166
+ raise "无法登录 JPS,请检查配置"
167
+ end
168
+
169
+ # 使用 PgyerHelper 的便捷方法发送工作流消息
170
+ result = pgyer_helper.send_workflow_message(
171
+ project_id: @project_id,
172
+ workflow_id: @workflow_id,
173
+ commit_id: @git_commit_id,
174
+ branch: @branch,
175
+ single: @single
176
+ )
177
+
178
+ if result[:success]
179
+ puts " ✓ 工作流消息发送成功"
180
+ else
181
+ if ENV['PINDO_DEBUG']
182
+ puts "[PINDO_DEBUG] send_workflow_message 返回结果: #{result.inspect}"
183
+ end
184
+
185
+ raise "工作流消息发送失败: #{result[:error]}"
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.14.4"
9
+ VERSION = "5.14.5"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'