@taole/deploy-helper 0.3.2 → 0.3.4
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/lib/pipelineApi.mjs +12 -8
- package/package.json +2 -2
package/lib/pipelineApi.mjs
CHANGED
|
@@ -78,9 +78,9 @@ export function setDevToken(token) {
|
|
|
78
78
|
async function getPipelineInfoByName(name) {
|
|
79
79
|
let pipeline = null;
|
|
80
80
|
try {
|
|
81
|
-
const pipelines = await listPipelinesFunc(organizationId, { pipelineName: name, perPage:
|
|
81
|
+
const pipelines = await listPipelinesFunc(organizationId, { pipelineName: name, perPage: 50, page: 1 });
|
|
82
82
|
if (pipelines && Array.isArray(pipelines.items) && pipelines.items.length > 0) {
|
|
83
|
-
pipeline = pipelines.items
|
|
83
|
+
pipeline = pipelines.items.find(item => item.name === name);
|
|
84
84
|
}
|
|
85
85
|
} catch (error) {
|
|
86
86
|
throw new Error(`获取流水线信息失败, 请确认流水线名称: ${name} 是否正确或检查云效token的权限是否足够: ${error}`);
|
|
@@ -126,9 +126,13 @@ export function checkYunxiaoToken(config, mode) {
|
|
|
126
126
|
|
|
127
127
|
async function runSinglePipeline(pipeline, index, total) {
|
|
128
128
|
console.log(`开始处理流水线: ${pipeline.name}, 当前是第${index + 1}个, 总共${total}个`);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
let pipelineId = pipeline.id || "";
|
|
130
|
+
if (!pipelineId) {
|
|
131
|
+
// 获取流水线信息
|
|
132
|
+
const pipelineInfo = await getPipelineInfoByName(pipeline.name);
|
|
133
|
+
pipelineId = pipelineInfo.id;
|
|
134
|
+
}
|
|
135
|
+
console.log(`流水线${pipeline.name}的id: ${pipelineId}`);
|
|
132
136
|
|
|
133
137
|
// 处理分支强推的问题
|
|
134
138
|
const force2Branch = pipeline.force2Branch;
|
|
@@ -159,9 +163,9 @@ async function runSinglePipeline(pipeline, index, total) {
|
|
|
159
163
|
}
|
|
160
164
|
// TODO: PERF: 获取流水线信息后, 可以缓存下来, 避免每次都重新获取
|
|
161
165
|
// TODO: 触发流水线时, 可以传入参数, 比如分支, 比如环境, 但是不知道为什么覆盖不了。这里先不传了
|
|
162
|
-
const runId = await createPipelineRunFunc(organizationId,
|
|
163
|
-
const piplineRunDetailUrl = `https://flow.aliyun.com/pipelines/${
|
|
164
|
-
console.log(`流水线${
|
|
166
|
+
const runId = await createPipelineRunFunc(organizationId, pipelineId, {});
|
|
167
|
+
const piplineRunDetailUrl = `https://flow.aliyun.com/pipelines/${pipelineId}/builds/${runId}`;
|
|
168
|
+
console.log(`流水线${pipeline.name}触发成功,流水线执行id: ${runId}, 流水线执行详情: ${piplineRunDetailUrl}`);
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
export async function runPipeline(config, mode) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taole/deploy-helper",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "脚本部署工具,用于将项目部署到测试环境或生产环境",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"author": "",
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"alibabacloud-devops-mcp-server": "
|
|
27
|
+
"alibabacloud-devops-mcp-server": "*",
|
|
28
28
|
"node-scp": "^0.0.25",
|
|
29
29
|
"simple-git": "^3.28.0"
|
|
30
30
|
}
|