@taole/deploy-helper 0.4.0 → 0.4.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.
@@ -155,23 +155,35 @@ async function getPipelineInfoByName(name) {
155
155
  * @param {number} interval 轮询间隔时间
156
156
  * @returns 流水线执行详情
157
157
  */
158
- async function waitPipelineRunFinish(pipelineID, runId, interval = 3000) {
158
+ async function waitPipelineRunFinish(pipelineID, runId, interval = 5000) {
159
159
  const pipelineRunDetailUrl = `https://flow.aliyun.com/pipelines/${pipelineID}/builds/${runId}`;
160
160
  log(`开始轮询至流水线执行完成`);
161
161
  let runDetail = await getPipelineRunFunc(organizationId, pipelineID, runId);
162
+ let passFailedCount = 0;
163
+ let passFailedMaxCount = 3;
162
164
  while (runDetail.status === "RUNNING" || runDetail.status === "WAITING") {
163
165
  const { stage, job } = getCurrentJob(runDetail);
164
166
  log(`流水线执行状态: ${runDetail.status},阶段: ${stage.name},任务: ${job.name},等${interval / 1000}秒后重新轮询`);
165
167
  if (runDetail.status === "WAITING") {
166
168
  if (stage && job) {
167
169
  log(`尝试自动通过人工卡点`);
168
- const isPass = await passPipelineJob(pipelineID, runId, job.id);
169
- if (isPass) {
170
- log(`人工卡点通过`);
171
- } else {
172
- log(`人工卡点通过失败`);
173
- break;
170
+ try {
171
+ const isPass = await passPipelineJob(pipelineID, runId, job.id);
172
+ if (isPass) {
173
+ log(`人工卡点通过`);
174
+ } else {
175
+ log(`人工卡点通过失败`);
176
+ passFailedCount++;
177
+ }
178
+ } catch (error) {
179
+ passFailedCount++;
180
+ log(`人工卡点通过失败`, error);
174
181
  }
182
+
183
+ }
184
+ if(passFailedCount >= passFailedMaxCount) {
185
+ log(`人工卡点通过失败次数超过最大值, 放弃`);
186
+ break;
175
187
  }
176
188
  }
177
189
  await new Promise(resolve => setTimeout(resolve, interval));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/deploy-helper",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "脚本部署工具,用于将项目部署到测试环境或生产环境",
5
5
  "main": "index.mjs",
6
6
  "type": "module",