@taole/deploy-helper 0.3.5 → 0.3.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.
- package/index.mjs +58 -51
- package/lib/pipelineApi.mjs +14 -13
- package/lib/util.mjs +17 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { join, basename, dirname } from "path";
|
|
|
6
6
|
import { simpleGit } from 'simple-git';
|
|
7
7
|
import { homedir } from 'os'
|
|
8
8
|
import { runPipeline, checkYunxiaoToken, triggerPipeline } from './lib/pipelineApi.mjs';
|
|
9
|
+
import { setDebug, log } from './lib/util.mjs';
|
|
9
10
|
|
|
10
11
|
const TEST_SERVER_HOST = "192.168.0.35";
|
|
11
12
|
/**
|
|
@@ -18,7 +19,7 @@ async function loadConfig() {
|
|
|
18
19
|
const configJson = JSON.parse(fs.readFileSync(configJsonPath, "utf-8"));
|
|
19
20
|
return configJson;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
log(`deploy.config.json不存在, 请先创建`);
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -26,7 +27,7 @@ async function initConfigJson() {
|
|
|
26
27
|
// check if deploy.config.json exists
|
|
27
28
|
const configJsonPath = join(process.cwd(), "deploy.config.json");
|
|
28
29
|
if (fs.existsSync(configJsonPath)) {
|
|
29
|
-
|
|
30
|
+
log(`deploy.config.json已存在, 请勿重复创建`);
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -52,7 +53,7 @@ async function initConfigJson() {
|
|
|
52
53
|
}
|
|
53
54
|
}`;
|
|
54
55
|
fs.writeFileSync(configJsonPath, content, { encoding: "utf-8" });
|
|
55
|
-
|
|
56
|
+
log(`deploy.config.json创建成功`);
|
|
56
57
|
process.exit(0);
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -72,7 +73,7 @@ async function getScpClient() {
|
|
|
72
73
|
if (fs.existsSync(sshKeyPath)) {
|
|
73
74
|
scpClientConfig.privateKey = fs.readFileSync(sshKeyPath, "utf-8");
|
|
74
75
|
} else {
|
|
75
|
-
|
|
76
|
+
log(`${sshKeyPath}不存在, 建议配置本机ssh免密登录, 参考地址:https://foochane.cn/article/2019061601.html`);
|
|
76
77
|
}
|
|
77
78
|
scpClient = await Client(scpClientConfig);
|
|
78
79
|
return scpClient;
|
|
@@ -83,8 +84,14 @@ async function getScpClient() {
|
|
|
83
84
|
|
|
84
85
|
async function main() {
|
|
85
86
|
|
|
87
|
+
// process.argv.includes("--debug") ||
|
|
88
|
+
// 默认开启debug debug目前只是打印日志的时候额外打印时间
|
|
89
|
+
setDebug(true);
|
|
90
|
+
|
|
91
|
+
log("deploy-helper start");
|
|
92
|
+
|
|
86
93
|
// await devTest();
|
|
87
|
-
//
|
|
94
|
+
// log(`process.argv: ${process.argv[2]} ${process.argv[3]} ${process.argv[4]}`);
|
|
88
95
|
|
|
89
96
|
// return;
|
|
90
97
|
// other commands
|
|
@@ -103,7 +110,7 @@ async function main() {
|
|
|
103
110
|
console.log(`command: scp {file} {dest} 复制文件{file}到OfficialSite测试服务器{dest}`);
|
|
104
111
|
console.log(`command: scpevt {file} 复制文件{file}到events测试服务器{file}`);
|
|
105
112
|
console.log(`command: scpevt {file} {dest} 复制文件{file}到events测试服务器{dest}`);
|
|
106
|
-
|
|
113
|
+
log(`command: pipeline {pipelineName|pipelineId} 触发流水线{pipelineName|pipelineId}`);
|
|
107
114
|
process.exit(0);
|
|
108
115
|
} else if (command === "init") {
|
|
109
116
|
await initConfigJson();
|
|
@@ -111,18 +118,18 @@ async function main() {
|
|
|
111
118
|
} else if (["scp", "scpevt"].includes(command)) {
|
|
112
119
|
const file = process.argv[3];
|
|
113
120
|
if (!file) {
|
|
114
|
-
|
|
121
|
+
log(`file参数不能为空`);
|
|
115
122
|
process.exit(1);
|
|
116
123
|
}
|
|
117
124
|
const workDir = process.cwd(); // 当前项目根目录
|
|
118
125
|
|
|
119
126
|
const srcFilePath = join(workDir, file);
|
|
120
127
|
if (!fs.existsSync(srcFilePath)) {
|
|
121
|
-
|
|
128
|
+
log(`${srcFilePath}不存在`);
|
|
122
129
|
process.exit(1);
|
|
123
130
|
}
|
|
124
131
|
if (fs.statSync(srcFilePath).isDirectory()) {
|
|
125
|
-
|
|
132
|
+
log(`${srcFilePath}是目录, 不支持scp目录`);
|
|
126
133
|
process.exit(1);
|
|
127
134
|
}
|
|
128
135
|
// 获取srcFilePath的目录
|
|
@@ -130,33 +137,33 @@ async function main() {
|
|
|
130
137
|
const fileName = basename(srcFilePath);
|
|
131
138
|
const dest = process.argv[4] || fileName;
|
|
132
139
|
if (dest.includes("/") || dest.includes("\\")) {
|
|
133
|
-
|
|
140
|
+
log(`dest不能包含/或\\`);
|
|
134
141
|
process.exit(1);
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
if (workDir !== fileDir) {
|
|
138
|
-
|
|
145
|
+
log(`仅支持scp当前目录下的文件(不带子目录)`);
|
|
139
146
|
process.exit(1);
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
const destPath = "/home/web/website/tuwan_www/templets/static/play/" + (command === 'scp' ? '' : 'events/') + dest;
|
|
143
150
|
|
|
144
151
|
const scpClient = await getScpClient();
|
|
145
|
-
|
|
152
|
+
log(`scp: ${srcFilePath} -> ${TEST_SERVER_HOST}:${destPath}`);
|
|
146
153
|
await scpClient.uploadFile(srcFilePath, destPath);
|
|
147
|
-
|
|
154
|
+
log(`scp done.`);
|
|
148
155
|
process.exit(0);
|
|
149
156
|
} else if (command === "pipeline") {
|
|
150
157
|
const pipelineName = process.argv[3];
|
|
151
158
|
if (!pipelineName) {
|
|
152
|
-
|
|
159
|
+
log(`pipeline参数不能为空`);
|
|
153
160
|
process.exit(1);
|
|
154
161
|
}
|
|
155
162
|
try {
|
|
156
163
|
await triggerPipeline(pipelineName);
|
|
157
164
|
process.exit(0);
|
|
158
165
|
} catch (error) {
|
|
159
|
-
|
|
166
|
+
log(`触发流水线失败: ${error}`);
|
|
160
167
|
process.exit(1);
|
|
161
168
|
}
|
|
162
169
|
|
|
@@ -164,22 +171,22 @@ async function main() {
|
|
|
164
171
|
try {
|
|
165
172
|
const workDir = process.cwd(); // 当前项目根目录
|
|
166
173
|
const mode = process.argv[2] === 'prod' ? 'prod' : 'test'; // 部署环境
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
log(`deploy mode: ${mode}`);
|
|
175
|
+
log(`workDir: ${workDir}`);
|
|
169
176
|
|
|
170
177
|
// 读取配置
|
|
171
178
|
const config = await loadConfig();
|
|
172
|
-
//
|
|
179
|
+
// log(`config`, config);
|
|
173
180
|
|
|
174
181
|
// 检查配置格式
|
|
175
182
|
if (!config.assets || !config.assets.dest || !config.entry || !config.entry.dest) {
|
|
176
|
-
|
|
183
|
+
log(`配置格式错误, 请检查deploy.config.js或deploy.config.json`);
|
|
177
184
|
return;
|
|
178
185
|
}
|
|
179
186
|
|
|
180
187
|
const result = hasChangeMe(JSON.stringify(config));
|
|
181
188
|
if (result) {
|
|
182
|
-
|
|
189
|
+
log(`配置中存在默认值(CHANGE_ME), 请先修改配置`);
|
|
183
190
|
process.exit(1);
|
|
184
191
|
}
|
|
185
192
|
|
|
@@ -201,12 +208,12 @@ async function main() {
|
|
|
201
208
|
const assetsDest = join(workDir, config.assets.dest);
|
|
202
209
|
const entryDest = join(workDir, config.entry.dest);
|
|
203
210
|
if (!fs.existsSync(assetsDest)) {
|
|
204
|
-
|
|
211
|
+
log(`assets.dest路径不存在: ${assetsDest}, 请先创建`);
|
|
205
212
|
return;
|
|
206
213
|
}
|
|
207
214
|
// entry.dest
|
|
208
215
|
if (needHandleEntry && !fs.existsSync(entryDest)) {
|
|
209
|
-
|
|
216
|
+
log(`entry.dest路径不存在: ${entryDest}, 请先创建`);
|
|
210
217
|
return;
|
|
211
218
|
}
|
|
212
219
|
|
|
@@ -214,7 +221,7 @@ async function main() {
|
|
|
214
221
|
const assetsGit = simpleGit(assetsDest);
|
|
215
222
|
let assetsStatus = await assetsGit.status();
|
|
216
223
|
if (!assetsStatus.isClean()) {
|
|
217
|
-
|
|
224
|
+
log(`${assetsDest}目前有未提交内容, 请先处理`);
|
|
218
225
|
return;
|
|
219
226
|
}
|
|
220
227
|
|
|
@@ -224,7 +231,7 @@ async function main() {
|
|
|
224
231
|
entryGit = simpleGit(entryDest);
|
|
225
232
|
entryStatus = await entryGit.status();
|
|
226
233
|
if (!entryStatus.isClean()) {
|
|
227
|
-
|
|
234
|
+
log(`${entryDest}目前有未提交内容, 请先处理`);
|
|
228
235
|
return;
|
|
229
236
|
}
|
|
230
237
|
}
|
|
@@ -234,11 +241,11 @@ async function main() {
|
|
|
234
241
|
// const currentGit = simpleGit(workDir);
|
|
235
242
|
// const currentStatus = await currentGit.status();
|
|
236
243
|
// if (!currentStatus.isClean()) {
|
|
237
|
-
//
|
|
244
|
+
// log(`当前项目有未提交内容, 请先处理`);
|
|
238
245
|
// process.exit(1);
|
|
239
246
|
// }
|
|
240
247
|
// if (currentStatus.branch !== currentProdBranch) {
|
|
241
|
-
//
|
|
248
|
+
// log(`当前项目分支${currentStatus.branch}不是${currentProdBranch}分支, 请切换至${currentProdBranch}分支再执行prod命令`);
|
|
242
249
|
// process.exit(1);
|
|
243
250
|
// }
|
|
244
251
|
// }
|
|
@@ -246,14 +253,14 @@ async function main() {
|
|
|
246
253
|
// 3. 检查assets项目分支,并切换至master分支
|
|
247
254
|
// assets项目固定使用master分支
|
|
248
255
|
if (assetsStatus.current !== "master") {
|
|
249
|
-
|
|
256
|
+
log(`${assetsDest}当前分支不是master, 切换至master分支`);
|
|
250
257
|
await assetsGit.checkout("master");
|
|
251
|
-
|
|
258
|
+
log(`${assetsDest}切换至master分支成功`);
|
|
252
259
|
}
|
|
253
260
|
if (needHandleEntry && entryStatus.current !== entryTargetBranch) {
|
|
254
|
-
|
|
261
|
+
log(`${entryDest}当前分支不是${entryTargetBranch}, 切换至${entryTargetBranch}分支`);
|
|
255
262
|
await entryGit.checkout(entryTargetBranch);
|
|
256
|
-
|
|
263
|
+
log(`${entryDest}切换至${entryTargetBranch}分支成功`);
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
// 4. 执行git pull
|
|
@@ -269,7 +276,7 @@ async function main() {
|
|
|
269
276
|
for (const [src, dest] of Object.entries(assetsFiles)) {
|
|
270
277
|
const srcPath = join(workDir, src);
|
|
271
278
|
if (!fs.existsSync(srcPath)) {
|
|
272
|
-
|
|
279
|
+
log(`${srcPath}不存在,请确认构建产物是否正确`);
|
|
273
280
|
return;
|
|
274
281
|
}
|
|
275
282
|
const destPath = join(assetsDest, dest);
|
|
@@ -278,28 +285,28 @@ async function main() {
|
|
|
278
285
|
} else {
|
|
279
286
|
fs.copyFileSync(srcPath, destPath);
|
|
280
287
|
}
|
|
281
|
-
|
|
288
|
+
log(`assets copy: ${srcPath} -> ${destPath}`);
|
|
282
289
|
assetsFilesCount++;
|
|
283
290
|
}
|
|
284
|
-
//
|
|
291
|
+
// log(`assets copy done.`);
|
|
285
292
|
// 5.2 复制entry
|
|
286
293
|
if (needHandleEntry) {
|
|
287
294
|
const entryFiles = config.entry.files;
|
|
288
295
|
for (const [src, dest] of Object.entries(entryFiles)) {
|
|
289
296
|
const srcPath = join(workDir, src);
|
|
290
297
|
if (!fs.existsSync(srcPath)) {
|
|
291
|
-
|
|
298
|
+
log(`${srcPath}不存在,请确认构建产物是否正确`);
|
|
292
299
|
return;
|
|
293
300
|
}
|
|
294
301
|
if (fs.statSync(srcPath).isDirectory()) {
|
|
295
|
-
|
|
302
|
+
log(`entry: ${srcPath}是目录,不支持entry为目录的部署`);
|
|
296
303
|
return;
|
|
297
304
|
}
|
|
298
305
|
const destPath = join(entryDest, dest);
|
|
299
306
|
fs.copyFileSync(srcPath, destPath);
|
|
300
|
-
|
|
307
|
+
log(`entry copy: ${srcPath} -> ${destPath}`);
|
|
301
308
|
}
|
|
302
|
-
//
|
|
309
|
+
// log(`entry copy done.`);
|
|
303
310
|
}
|
|
304
311
|
|
|
305
312
|
// 6. 提交
|
|
@@ -311,10 +318,10 @@ async function main() {
|
|
|
311
318
|
await assetsGit.add(".");
|
|
312
319
|
const assetsCommit = `${config.assets.commit || "feat:部署资源文件"} by deploy-helper`;
|
|
313
320
|
const assetsCommitResult = await assetsGit.commit(assetsCommit);
|
|
314
|
-
|
|
315
|
-
|
|
321
|
+
log(`assets commit: ${assetsCommit}`);
|
|
322
|
+
log(`assets commit: ${JSON.stringify(assetsCommitResult.summary)}`);
|
|
316
323
|
} else {
|
|
317
|
-
|
|
324
|
+
log(`${assetsDest} 未发现修改内容,跳过提交`);
|
|
318
325
|
}
|
|
319
326
|
|
|
320
327
|
if (needHandleEntry) {
|
|
@@ -324,10 +331,10 @@ async function main() {
|
|
|
324
331
|
await entryGit.add(".");
|
|
325
332
|
const entryCommit = `${config.entry.commit || "feat:部署入口文件"} by deploy-helper`;
|
|
326
333
|
const entryCommitResult = await entryGit.commit(entryCommit);
|
|
327
|
-
|
|
328
|
-
|
|
334
|
+
log(`entry commit: ${entryCommit}`);
|
|
335
|
+
log(`entry commit: ${JSON.stringify(entryCommitResult.summary)}`);
|
|
329
336
|
} else {
|
|
330
|
-
|
|
337
|
+
log(`${entryDest} 未发现修改内容,跳过提交`);
|
|
331
338
|
}
|
|
332
339
|
}
|
|
333
340
|
|
|
@@ -338,7 +345,7 @@ async function main() {
|
|
|
338
345
|
} catch (error) {
|
|
339
346
|
await assetsGit.push();
|
|
340
347
|
}
|
|
341
|
-
|
|
348
|
+
log(`assets push done.`);
|
|
342
349
|
}
|
|
343
350
|
if (canPushEntry) {
|
|
344
351
|
try {
|
|
@@ -346,7 +353,7 @@ async function main() {
|
|
|
346
353
|
} catch (error) {
|
|
347
354
|
await entryGit.push();
|
|
348
355
|
}
|
|
349
|
-
|
|
356
|
+
log(`entry push done.`);
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
try {
|
|
@@ -357,15 +364,15 @@ async function main() {
|
|
|
357
364
|
for (const [src, dest] of Object.entries(syncTestFiles)) {
|
|
358
365
|
const srcPath = join(workDir, src);
|
|
359
366
|
const destPath = "/home/web/website/tuwan_www/templets/static/play/" + dest;
|
|
360
|
-
|
|
367
|
+
log(`scp: ${srcPath} -> ${TEST_SERVER_HOST}:${destPath}`);
|
|
361
368
|
await scpClient.uploadFile(srcPath, destPath)
|
|
362
369
|
}
|
|
363
370
|
}
|
|
364
371
|
} catch (error) {
|
|
365
|
-
|
|
366
|
-
|
|
372
|
+
log(`scp error: ${error}`);
|
|
373
|
+
log(`复制文件到测试环境服务器失败, 建议配置本机ssh免密登录, 参考地址:https://foochane.cn/article/2019061601.html`);
|
|
367
374
|
if (assetsFilesCount > 0) {
|
|
368
|
-
|
|
375
|
+
log(`不过请放心,构建产物的assets已经处理完成,只要手动处理index.html文件即可。`);
|
|
369
376
|
}
|
|
370
377
|
process.exit(1);
|
|
371
378
|
}
|
|
@@ -374,11 +381,11 @@ async function main() {
|
|
|
374
381
|
// 处理触发流水线的任务
|
|
375
382
|
await runPipeline(config, mode);
|
|
376
383
|
|
|
377
|
-
|
|
384
|
+
log(`deploy-helper deploy done.`);
|
|
378
385
|
process.exit(0);
|
|
379
386
|
|
|
380
387
|
} catch (error) {
|
|
381
|
-
|
|
388
|
+
log(`error occurred in deploy-helper`, error);
|
|
382
389
|
process.exit(1);
|
|
383
390
|
}
|
|
384
391
|
}
|
package/lib/pipelineApi.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { homedir } from 'node:os';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import simpleGit from 'simple-git';
|
|
5
|
+
import { log, isDebug } from './util.mjs';
|
|
5
6
|
|
|
6
7
|
import { createPipelineRunFunc, listPipelinesFunc, getPipelineFunc } from '../modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipeline.js'
|
|
7
8
|
|
|
@@ -35,7 +36,7 @@ export function getYunxiaoToken(pipelineConfig) {
|
|
|
35
36
|
if (devToken) {
|
|
36
37
|
if (isFirstFoundToken) {
|
|
37
38
|
isFirstFoundToken = false;
|
|
38
|
-
|
|
39
|
+
log(`将使用devToken`);
|
|
39
40
|
}
|
|
40
41
|
return devToken;
|
|
41
42
|
}
|
|
@@ -45,7 +46,7 @@ export function getYunxiaoToken(pipelineConfig) {
|
|
|
45
46
|
if (token) {
|
|
46
47
|
if (isFirstFoundToken) {
|
|
47
48
|
isFirstFoundToken = false;
|
|
48
|
-
|
|
49
|
+
log(`将使用来自环境变量YUNXIAO_ACCESS_TOKEN的云效token`);
|
|
49
50
|
}
|
|
50
51
|
return token;
|
|
51
52
|
}
|
|
@@ -62,7 +63,7 @@ export function getYunxiaoToken(pipelineConfig) {
|
|
|
62
63
|
if (token) {
|
|
63
64
|
if (isFirstFoundToken) {
|
|
64
65
|
isFirstFoundToken = false;
|
|
65
|
-
|
|
66
|
+
log(`将使用来自${userDeployHelperDir}的云效token`);
|
|
66
67
|
}
|
|
67
68
|
return token;
|
|
68
69
|
}
|
|
@@ -109,7 +110,7 @@ export async function triggerPipeline(pipelineName) {
|
|
|
109
110
|
}
|
|
110
111
|
const runId = await createPipelineRunFunc(organizationId, pipelineID, {});
|
|
111
112
|
const pipelineRunDetailUrl = `https://flow.aliyun.com/pipelines/${pipelineID}/builds/${runId}`;
|
|
112
|
-
|
|
113
|
+
log(`流水线${name}[${pipelineID}]触发成功,流水线执行id: ${runId}, 流水线执行详情: ${pipelineRunDetailUrl}`);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
|
|
@@ -145,14 +146,14 @@ export function checkYunxiaoToken(config, mode) {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
async function runSinglePipeline(pipeline, index, total) {
|
|
148
|
-
|
|
149
|
+
log(`开始处理流水线: ${pipeline.name}, 当前是第${index + 1}个, 总共${total}个`);
|
|
149
150
|
let pipelineId = pipeline.id || "";
|
|
150
151
|
if (!pipelineId) {
|
|
151
152
|
// 获取流水线信息
|
|
152
153
|
const pipelineInfo = await getPipelineInfoByName(pipeline.name);
|
|
153
154
|
pipelineId = pipelineInfo.id;
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
+
log(`流水线${pipeline.name}的id: ${pipelineId}`);
|
|
156
157
|
|
|
157
158
|
// 处理分支强推的问题
|
|
158
159
|
const force2Branch = pipeline.force2Branch;
|
|
@@ -160,32 +161,32 @@ async function runSinglePipeline(pipeline, index, total) {
|
|
|
160
161
|
let repo = pipeline.repo || "./";
|
|
161
162
|
repo = join(process.cwd(), repo);
|
|
162
163
|
if (!fs.existsSync(repo)) {
|
|
163
|
-
|
|
164
|
+
log(`仓库${repo}有未提交的修改, 跳过流水线处理`);
|
|
164
165
|
return;
|
|
165
166
|
}
|
|
166
167
|
// 强推到指定分支
|
|
167
168
|
const git = simpleGit(repo);
|
|
168
169
|
const gitStatus = await git.status();
|
|
169
170
|
if (!gitStatus.isClean()) {
|
|
170
|
-
|
|
171
|
+
log(`仓库${repo}有未提交的修改, 跳过流水线处理`);
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
174
|
if (gitStatus.current !== force2Branch.src) {
|
|
174
|
-
|
|
175
|
+
log(`仓库${repo}当前分支不是${force2Branch.src}, 切换到${force2Branch.src}`);
|
|
175
176
|
await git.checkout(force2Branch.src);
|
|
176
|
-
|
|
177
|
+
log(`仓库${repo}切换到${force2Branch.src}完成`);
|
|
177
178
|
}
|
|
178
179
|
await git.pull();
|
|
179
180
|
await git.push();
|
|
180
181
|
// git push origin master-test-0513:test --force
|
|
181
182
|
await git.raw("push", "origin", `${force2Branch.src}:${force2Branch.dest}`, "--force");
|
|
182
|
-
|
|
183
|
+
log(`仓库${repo}强推${force2Branch.src}到${force2Branch.dest}完成`);
|
|
183
184
|
}
|
|
184
185
|
// TODO: PERF: 获取流水线信息后, 可以缓存下来, 避免每次都重新获取
|
|
185
186
|
// TODO: 触发流水线时, 可以传入参数, 比如分支, 比如环境, 但是不知道为什么覆盖不了。这里先不传了
|
|
186
187
|
const runId = await createPipelineRunFunc(organizationId, pipelineId, {});
|
|
187
188
|
const piplineRunDetailUrl = `https://flow.aliyun.com/pipelines/${pipelineId}/builds/${runId}`;
|
|
188
|
-
|
|
189
|
+
log(`流水线${pipeline.name}触发成功,流水线执行id: ${runId}, 流水线执行详情: ${piplineRunDetailUrl}`);
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
export async function runPipeline(config, mode) {
|
|
@@ -196,7 +197,7 @@ export async function runPipeline(config, mode) {
|
|
|
196
197
|
}
|
|
197
198
|
const token = getYunxiaoToken(pipelineConfig);
|
|
198
199
|
if (!token) {
|
|
199
|
-
|
|
200
|
+
log(`未设置云效token, 此次流水线未自动执行: ${JSON.stringify(pipelineConfig)}`);
|
|
200
201
|
}
|
|
201
202
|
process.env.YUNXIAO_ACCESS_TOKEN = token;
|
|
202
203
|
|
package/lib/util.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
let _isDebug = false;
|
|
2
|
+
export function setDebug(debug) {
|
|
3
|
+
_isDebug = debug;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function isDebug() {
|
|
7
|
+
return _isDebug;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function log(...args) {
|
|
11
|
+
if (_isDebug) {
|
|
12
|
+
// 打印时间
|
|
13
|
+
console.log(`[${new Date().toLocaleString()}]`, ...args);
|
|
14
|
+
} else {
|
|
15
|
+
console.log(...args);
|
|
16
|
+
}
|
|
17
|
+
}
|