diff --git a/packages/plugins/plugin-lib/src/ssh/ssh.ts b/packages/plugins/plugin-lib/src/ssh/ssh.ts index b7d203a6..e80079a4 100644 --- a/packages/plugins/plugin-lib/src/ssh/ssh.ts +++ b/packages/plugins/plugin-lib/src/ssh/ssh.ts @@ -506,10 +506,6 @@ export class SshClient { isWinCmd = await this.isCmd(conn); } - if (isLinux && options.stopOnError !== false) { - script = "set -e\n" + script; - } - if (options.env) { for (const key in options.env) { if (isLinux) { @@ -525,10 +521,10 @@ export class SshClient { } if (isWinCmd) { - //组合成&&的形式 if (typeof script === "string") { script = script.split("\n"); } + //组合成&&的形式 script = envScripts.concat(script); script = script as Array; script = script.join(" && "); @@ -543,6 +539,10 @@ export class SshClient { } } + if (isLinux && options.stopOnError !== false) { + script = "set -e\n" + script; + } + return await conn.exec(script as string, { throwOnStdErr }); }, });