@taole/deploy-helper 0.5.2 → 0.5.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/index.mjs +16 -7
- package/lib/pipelineApi.mjs +14 -11
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -56,6 +56,14 @@ async function initConfigJson() {
|
|
|
56
56
|
},
|
|
57
57
|
"testSync": {
|
|
58
58
|
"dist/index.html": "events/CHANGE_ME.htm"
|
|
59
|
+
},
|
|
60
|
+
"prodPipeline":{
|
|
61
|
+
"pipelines": [
|
|
62
|
+
{
|
|
63
|
+
"name": "OfficialSite OR SOMEOTHER",
|
|
64
|
+
"waitResult": true
|
|
65
|
+
}
|
|
66
|
+
]
|
|
59
67
|
}
|
|
60
68
|
}`;
|
|
61
69
|
fs.writeFileSync(configJsonPath, content, { encoding: "utf-8" });
|
|
@@ -73,14 +81,15 @@ async function getScpClient() {
|
|
|
73
81
|
const scpClientConfig = {
|
|
74
82
|
host: TEST_SERVER_HOST,
|
|
75
83
|
username: 'root',
|
|
76
|
-
tryKeyboard:
|
|
77
|
-
|
|
78
|
-
const sshKeyPath = join(homedir(), ".ssh/id_rsa");
|
|
79
|
-
if (fs.existsSync(sshKeyPath)) {
|
|
80
|
-
scpClientConfig.privateKey = fs.readFileSync(sshKeyPath, "utf-8");
|
|
81
|
-
} else {
|
|
82
|
-
log(`${sshKeyPath}不存在, 建议配置本机ssh免密登录, 参考地址:https://foochane.cn/article/2019061601.html`);
|
|
84
|
+
tryKeyboard: false,
|
|
85
|
+
password: 'tuwan123!@#',
|
|
83
86
|
}
|
|
87
|
+
// const sshKeyPath = join(homedir(), ".ssh/id_rsa");
|
|
88
|
+
// if (fs.existsSync(sshKeyPath)) {
|
|
89
|
+
// scpClientConfig.privateKey = fs.readFileSync(sshKeyPath, "utf-8");
|
|
90
|
+
// } else {
|
|
91
|
+
// log(`${sshKeyPath}不存在, 建议配置本机ssh免密登录, 参考地址:https://foochane.cn/article/2019061601.html`);
|
|
92
|
+
// }
|
|
84
93
|
scpClient = await Client(scpClientConfig);
|
|
85
94
|
return scpClient;
|
|
86
95
|
}
|
package/lib/pipelineApi.mjs
CHANGED
|
@@ -166,18 +166,21 @@ async function waitPipelineRunFinish(pipelineID, runId, interval = 5000) {
|
|
|
166
166
|
log(`流水线执行状态: ${runDetail.status},阶段: ${stage.name},任务: ${job.name},${interval / 1000}秒后再次查询`);
|
|
167
167
|
if (runDetail.status === "WAITING") {
|
|
168
168
|
if (stage && job) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
169
|
+
const PassPipelineValidate = (job.actions || []).find(action => action.type === "PassPipelineValidate");
|
|
170
|
+
if (PassPipelineValidate) {
|
|
171
|
+
log(`尝试自动通过人工卡点`);
|
|
172
|
+
try {
|
|
173
|
+
const isPass = await passPipelineJob(pipelineID, runId, job.id);
|
|
174
|
+
if (isPass) {
|
|
175
|
+
log(`人工卡点通过`);
|
|
176
|
+
} else {
|
|
177
|
+
log(`人工卡点通过失败`);
|
|
178
|
+
passFailedCount++;
|
|
179
|
+
}
|
|
180
|
+
} catch (error) {
|
|
176
181
|
passFailedCount++;
|
|
182
|
+
log(`人工卡点通过失败`, error);
|
|
177
183
|
}
|
|
178
|
-
} catch (error) {
|
|
179
|
-
passFailedCount++;
|
|
180
|
-
log(`人工卡点通过失败`, error);
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
186
|
if (passFailedCount >= passFailedMaxCount) {
|
|
@@ -202,7 +205,7 @@ async function waitPipelineRunFinish(pipelineID, runId, interval = 5000) {
|
|
|
202
205
|
* @param {*} targetBranch 指定分支, 如果为空,则不指定分支
|
|
203
206
|
* @returns 流水线信息和源码仓库信息, 触发流水线参数
|
|
204
207
|
*/
|
|
205
|
-
async function getPipelineInfoDetail(pipelineName, targetBranch = ""){
|
|
208
|
+
async function getPipelineInfoDetail(pipelineName, targetBranch = "") {
|
|
206
209
|
let pipelineID = "";
|
|
207
210
|
let pipelineInfo = null;
|
|
208
211
|
let repoInfo = null;
|