mirror of
https://github.com/appleboy/drone-ssh.git
synced 2026-06-04 10:15:07 +08:00
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
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user