65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/pindo/command/jps/apptest.rb', line 65
def run
project_path = Dir.pwd
pgyer_helper = PgyerHelper.share_instace
pgyer_helper.login
app_info_obj, workflow_info = pgyer_helper.prepare_upload(
working_directory: project_path,
conf: @args_conf,
package_type: 'ipa' )
if app_info_obj.nil?
raise Informative, "未找到 JPS 项目,请检查配置文件或重新选择"
end
version_item_obj = pgyer_helper.get_versioon_history_item(
app_info_obj: app_info_obj,
list_select_flat: @args_list_flag
)
if version_item_obj.nil?
raise Informative, "没有找到上传记录"
end
pgyer_helper.print_app_version_info(
app_info_obj: app_info_obj,
app_version_info_obj: version_item_obj
)
tasks = []
message_type = @args_group_flag ? 'group' : 'self'
message_task = Pindo::TaskSystem::JPSMessageTask.new(
version_item_obj, app_info_obj: app_info_obj,
project_name: nil,
send_message_type: message_type
)
tasks << message_task
if @args_send_flag
git_app_info_obj, git_workflow_info = pgyer_helper.prepare_upload(
working_directory: project_path,
conf: @args_conf,
package_type: nil,
manage_type: "git"
)
git_commit_id = nil
git_commit_time = nil
git_commit_desc = nil
git_root = Pindo::GitHandler.git_root_directory(local_repo_dir: project_path)
if git_root
puts " 📍 检测到 Git 仓库,使用当前 commit..."
git_info = Pindo::GitHandler.get_latest_conventional_commit(project_dir: git_root)
git_commit_id = git_info[:commit_id]
git_commit_time = git_info[:commit_time]
git_commit_desc = git_info[:commit_desc]
if git_commit_id
puts " └─ Commit: #{git_commit_id[0..7]}"
puts " └─ Desc: #{git_commit_desc}" if git_commit_desc
end
else
puts " 📡 未检测到 Git 仓库,从工作流获取最新 commit..."
git_commit_id = pgyer_helper.get_workflow_latest_commit_id(
workflow_id: git_workflow_info["id"]
)
if git_commit_id
puts " └─ Commit: #{git_commit_id[0..7]}"
else
puts " └─ ⚠️ 未能获取工作流中的 commit,将尝试使用空 commit"
end
end
workflow_message_task = Pindo::TaskSystem::JPSWorkFlowMessageTask.new(
project_id: git_app_info_obj["id"],
workflow_id: git_workflow_info["id"],
git_commit_id: git_commit_id,
git_commit_time: git_commit_time,
git_commit_desc: git_commit_desc,
branch: 'master',
single: true,
app_info_obj: git_app_info_obj,
workflow_info: git_workflow_info
)
tasks << workflow_message_task
end
task_manager = Pindo::TaskSystem::TaskManager.instance
task_manager.clear_all
tasks.each { |task| task_manager.add_task(task) }
task_manager.start
report = task_manager.execution_report
if report[:success] > 0
puts "\n✅ 消息发送完成!"
else
raise Informative, "消息发送失败"
end
end
|