mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-07-02 21:52:51 +08:00
Added a flag for connection timeouts
This commit is contained in:
parent
c816c75fc6
commit
fd259fd403
2
DOCS.md
2
DOCS.md
@ -10,6 +10,7 @@ The following parameters are used to configure the plugin:
|
|||||||
* **user** - user to log in as on the remote machine
|
* **user** - user to log in as on the remote machine
|
||||||
* **key** - private SSH key for the remote machine
|
* **key** - private SSH key for the remote machine
|
||||||
* **sleep** - sleep for seconds between host connections
|
* **sleep** - sleep for seconds between host connections
|
||||||
|
* **timeout** - timeout for the tcp connection attempt
|
||||||
* **commands** - list of commands to execute
|
* **commands** - list of commands to execute
|
||||||
|
|
||||||
The following secret values can be set to configure the plugin.
|
The following secret values can be set to configure the plugin.
|
||||||
@ -19,6 +20,7 @@ The following secret values can be set to configure the plugin.
|
|||||||
* **SSH_USER** - corresponds to **user**
|
* **SSH_USER** - corresponds to **user**
|
||||||
* **SSH_KEY** - corresponds to **key**
|
* **SSH_KEY** - corresponds to **key**
|
||||||
* **SSH_SLEEP** - corresponds to **sleep**
|
* **SSH_SLEEP** - corresponds to **sleep**
|
||||||
|
* **SSH_TIMEOUT** - corresponds to **timeout**
|
||||||
|
|
||||||
It is highly recommended to put the **SSH_KEY** into a secret so it is not
|
It is highly recommended to put the **SSH_KEY** into a secret so it is not
|
||||||
exposed to users. This can be done using the drone-cli.
|
exposed to users. This can be done using the drone-cli.
|
||||||
|
6
main.go
6
main.go
@ -44,6 +44,11 @@ func main() {
|
|||||||
Usage: "sleep between hosts",
|
Usage: "sleep between hosts",
|
||||||
EnvVar: "PLUGIN_SLEEP,SSH_SLEEP",
|
EnvVar: "PLUGIN_SLEEP,SSH_SLEEP",
|
||||||
},
|
},
|
||||||
|
cli.DurationFlag{
|
||||||
|
Name: "timeout",
|
||||||
|
Usage: "connection timeout",
|
||||||
|
EnvVar: "PLUGIN_TIMEOUT,SSH_TIMEOUT",
|
||||||
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "commands",
|
Name: "commands",
|
||||||
Usage: "execute commands",
|
Usage: "execute commands",
|
||||||
@ -72,6 +77,7 @@ func run(c *cli.Context) error {
|
|||||||
Host: c.StringSlice("host"),
|
Host: c.StringSlice("host"),
|
||||||
Port: c.Int("port"),
|
Port: c.Int("port"),
|
||||||
Sleep: c.Int("sleep"),
|
Sleep: c.Int("sleep"),
|
||||||
|
Timeout: c.Duration("timeout"),
|
||||||
Commands: c.StringSlice("commands"),
|
Commands: c.StringSlice("commands"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ type (
|
|||||||
Host []string `json:"host"`
|
Host []string `json:"host"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Sleep int `json:"sleep"`
|
Sleep int `json:"sleep"`
|
||||||
|
Timeout time.Duration `json:"timeout"`
|
||||||
Commands []string `json:"commands"`
|
Commands []string `json:"commands"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config := &ssh.ClientConfig{
|
config := &ssh.ClientConfig{
|
||||||
|
Timeout: p.Config.Timeout,
|
||||||
User: p.Config.User,
|
User: p.Config.User,
|
||||||
Auth: []ssh.AuthMethod{
|
Auth: []ssh.AuthMethod{
|
||||||
ssh.PublicKeys(signer),
|
ssh.PublicKeys(signer),
|
||||||
|
Loading…
Reference in New Issue
Block a user