diff --git a/plugin.go b/plugin.go index 9d74469..dce3f16 100644 --- a/plugin.go +++ b/plugin.go @@ -16,6 +16,7 @@ var wg sync.WaitGroup const ( missingHostOrUser = "Error: missing server host or user" missingPasswordOrKey = "Error: can't connect without a private SSH key or password" + commandTimeOut = "Error: command timeout" ) type ( @@ -91,9 +92,12 @@ func (p Plugin) Exec() error { p.log(host, "commands: ", strings.Join(p.Config.Script, "\n")) outStr, errStr, isTimeout, err := ssh.Run(strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout) p.log(host, "outputs:", outStr) + if len(errStr) != 0 { + p.log(host, "errors:", outStr) + } - if !isTimeout || len(errStr) != 0 { - errChannel <- fmt.Errorf(errStr) + if !isTimeout { + errChannel <- fmt.Errorf(commandTimeOut) } if err != nil { diff --git a/plugin_test.go b/plugin_test.go index 154aee8..38139e2 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -120,21 +120,6 @@ func TestSSHCommandTimeOut(t *testing.T) { assert.NotNil(t, err) } -func TestSSHCommandNotFound(t *testing.T) { - plugin := Plugin{ - Config: Config{ - Host: []string{"localhost"}, - UserName: "drone-scp", - Port: 22, - KeyPath: "./tests/.ssh/id_rsa", - Script: []string{"whoami1234"}, - }, - } - - err := plugin.Exec() - assert.NotNil(t, err) -} - func TestProxyCommand(t *testing.T) { plugin := Plugin{ Config: Config{