From b37cffd704cd08b8bdd68a6e284706eabe59e78d Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 9 Jul 2025 15:43:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=A7=E8=A1=8Cwindows=20nginx?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=97=B6=EF=BC=8C=E6=94=B9=E4=B8=BAreturn=20?= =?UTF-8?q?code=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugins/plugin-lib/src/ssh/ssh.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/plugins/plugin-lib/src/ssh/ssh.ts b/packages/plugins/plugin-lib/src/ssh/ssh.ts index 4a105779..ccd12caf 100644 --- a/packages/plugins/plugin-lib/src/ssh/ssh.ts +++ b/packages/plugins/plugin-lib/src/ssh/ssh.ts @@ -204,9 +204,18 @@ export class AsyncSsh2Client { stream .on("close", (code: any, signal: any) => { this.logger.info(`[${this.connConf.host}][close]:code:${code}`); - if (opts.throwOnStdErr == null && this.windows) { - opts.throwOnStdErr = true; - } + /** + * ]pipeline 执行命令:[10.123.0.2][exec]:cd /d D:\nginx-1.27.5 && D:\nginx-1.27.5\nginx.exe -t && D:\nginx-1.27.5\nginx.exe -s reload + * [2025-07-09T10:24:11.219] [ERROR]pipeline - [10. 123.0. 2][error]: nginx: the configuration file D: \nginx-1.27. 5/conf/nginx. conf syntax is ok + * [2025-07-09T10:24:11.231] [ERROR][10. 123. 0. 2] [error]: nginx: configuration file D: \nginx-1.27.5/conf/nginx.conf test is successful + * pipeline- + * [2025-07-09T10:24:11.473] [INFO]pipeline -[10.123.0.2][close]:code:0 + * [2025-07-09T10:24:11.473][ERRoR] pipeline- [step][主机一执行远程主机脚本命令]: [Eror: nginx: the configuration fileD:\nginx-1.27.5/conf/nginx.conf syntax is ok + //需要忽略windows的错误 + */ + // if (opts.throwOnStdErr == null && this.windows) { + // opts.throwOnStdErr = true; + // } if (opts.throwOnStdErr && hasErrorLog) { reject(new Error(data)); } @@ -482,9 +491,9 @@ export class SshClient { * Set-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\cmd.exe" * @param options */ - async exec(options: { connectConf: SshAccess; script: string | Array; env?: any }): Promise { + async exec(options: { connectConf: SshAccess; script: string | Array; env?: any; throwOnStdErr?: boolean }): Promise { let { script } = options; - const { connectConf } = options; + const { connectConf, throwOnStdErr } = options; // this.logger.info('命令:', script); return await this._call({ @@ -529,7 +538,7 @@ export class SshClient { script = envScripts.join(newLine) + newLine + script; } } - return await conn.exec(script as string, {}); + return await conn.exec(script as string, { throwOnStdErr }); }, }); }