diff --git a/main.go b/main.go index c561ca3..9d7d82f 100644 --- a/main.go +++ b/main.go @@ -220,6 +220,11 @@ func main() { Usage: "pass all environment variable to shell script", EnvVars: []string{"PLUGIN_ALLENVS", "INPUT_ALLENVS"}, }, + &cli.BoolFlag{ + Name: "request-pty", + Usage: "request a pseudo-terminal from the server", + EnvVars: []string{"PLUGIN_REQUEST_PTY", "INPUT_REQUEST_PTY"}, + }, } // Override a template @@ -288,6 +293,7 @@ func run(c *cli.Context) error { Ciphers: c.StringSlice("ciphers"), UseInsecureCipher: c.Bool("useInsecureCipher"), AllEnvs: c.Bool("allenvs"), + RequireTty: c.Bool("request-pty"), Proxy: easyssh.DefaultConfig{ Key: c.String("proxy.ssh-key"), KeyPath: c.String("proxy.key-path"), diff --git a/plugin.go b/plugin.go index e52e959..56d5b76 100644 --- a/plugin.go +++ b/plugin.go @@ -44,6 +44,7 @@ type ( UseInsecureCipher bool EnvsFormat string AllEnvs bool + RequireTty bool } // Plugin structure @@ -85,6 +86,7 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { Ciphers: p.Config.Ciphers, Fingerprint: p.Config.Fingerprint, UseInsecureCipher: p.Config.UseInsecureCipher, + RequestPty: p.Config.RequireTty, Proxy: easyssh.DefaultConfig{ Server: p.Config.Proxy.Server, User: p.Config.Proxy.User, diff --git a/plugin_test.go b/plugin_test.go index 45cf264..e5c7f91 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -925,9 +925,9 @@ func TestSudoCommand(t *testing.T) { buffer bytes.Buffer expected = ` ======CMD====== - whoami + sudo su - -c "whoami" ======END====== - out: drone-scp + out: root ` ) @@ -941,6 +941,7 @@ func TestSudoCommand(t *testing.T) { `sudo su - -c "whoami"`, }, CommandTimeout: 10 * time.Second, + RequireTty: true, }, Writer: &buffer, }