From 5f79a61f890d139157d29504535e256c44ce353f Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 16 Apr 2026 17:04:53 +0800 Subject: [PATCH] fix: restore v1.8.2 debug ENV section behavior Move ENV debug logging before appending scriptCommands to env slice, so ======ENV====== only appears when Envs are configured and only contains export statements, matching v1.8.2 behavior. - revert TestCommandOutput: remove ENV section (no Envs configured) - revert TestEnvOutput: remove echo commands from ENV section --- plugin.go | 6 +++--- plugin_test.go | 17 ----------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/plugin.go b/plugin.go index 180f714..9c6213f 100644 --- a/plugin.go +++ b/plugin.go @@ -128,15 +128,15 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { } } - env = append(env, p.scriptCommands()...) - p.Config.Script = env - if p.Config.Debug && len(env) > 0 { p.log(host, "======ENV======") p.log(host, strings.Join(env, "\n")) p.log(host, "======END======") } + env = append(env, p.scriptCommands()...) + p.Config.Script = env + stdoutChan, stderrChan, doneChan, errChan, err := ssh.Stream( strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout, diff --git a/plugin_test.go b/plugin_test.go index d14b333..465490d 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -384,11 +384,6 @@ func TestCommandOutput(t *testing.T) { whoami uname localhost: ======END====== - localhost: ======ENV====== - localhost: pwd - whoami - uname - localhost: ======END====== localhost: /home/drone-scp localhost: drone-scp localhost: Linux @@ -397,11 +392,6 @@ func TestCommandOutput(t *testing.T) { whoami uname 127.0.0.1: ======END====== - 127.0.0.1: ======ENV====== - 127.0.0.1: pwd - whoami - uname - 127.0.0.1: ======END====== 127.0.0.1: /home/drone-scp 127.0.0.1: drone-scp 127.0.0.1: Linux @@ -618,13 +608,6 @@ func TestEnvOutput(t *testing.T) { export ENV_5='test'\''' export ENV_6='test"' export ENV_7='test,!#;?.@$~'\''"' - echo "[${ENV_1}]" - echo "[${ENV_2}]" - echo "[${ENV_3}]" - echo "[${ENV_4}]" - echo "[${ENV_5}]" - echo "[${ENV_6}]" - echo "[${ENV_7}]" ======END====== [test] [test test]