mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
fix: remove check error string.
This commit is contained in:
parent
e5dc646e5d
commit
c6042000fd
@ -16,6 +16,7 @@ var wg sync.WaitGroup
|
|||||||
const (
|
const (
|
||||||
missingHostOrUser = "Error: missing server host or user"
|
missingHostOrUser = "Error: missing server host or user"
|
||||||
missingPasswordOrKey = "Error: can't connect without a private SSH key or password"
|
missingPasswordOrKey = "Error: can't connect without a private SSH key or password"
|
||||||
|
commandTimeOut = "Error: command timeout"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -91,9 +92,12 @@ func (p Plugin) Exec() error {
|
|||||||
p.log(host, "commands: ", strings.Join(p.Config.Script, "\n"))
|
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)
|
outStr, errStr, isTimeout, err := ssh.Run(strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout)
|
||||||
p.log(host, "outputs:", outStr)
|
p.log(host, "outputs:", outStr)
|
||||||
|
if len(errStr) != 0 {
|
||||||
|
p.log(host, "errors:", outStr)
|
||||||
|
}
|
||||||
|
|
||||||
if !isTimeout || len(errStr) != 0 {
|
if !isTimeout {
|
||||||
errChannel <- fmt.Errorf(errStr)
|
errChannel <- fmt.Errorf(commandTimeOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -120,21 +120,6 @@ func TestSSHCommandTimeOut(t *testing.T) {
|
|||||||
assert.NotNil(t, err)
|
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) {
|
func TestProxyCommand(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Config: Config{
|
Config: Config{
|
||||||
|
Loading…
Reference in New Issue
Block a user