Merge pull request #32 from OliveTin/exec-without-shell
bugfix: Working stderr!
This commit is contained in:
commit
c263a84aa7
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"bytes"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -190,20 +191,27 @@ func (e stepExec) Exec(req *ExecutionRequest) bool {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(req.action.Timeout)*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(req.action.Timeout)*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
cmd := exec.CommandContext(ctx, "sh", "-c", req.finalParsedCommand)
|
var stdout bytes.Buffer
|
||||||
stdout, stderr := cmd.Output()
|
var stderr bytes.Buffer
|
||||||
|
|
||||||
if stderr != nil {
|
cmd := exec.CommandContext(ctx, "sh", "-c", req.finalParsedCommand)
|
||||||
req.logEntry.Stderr = stderr.Error()
|
cmd.Stdout = &stdout
|
||||||
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
|
runerr := cmd.Run()
|
||||||
|
|
||||||
|
req.logEntry.ExitCode = int32(cmd.ProcessState.ExitCode())
|
||||||
|
req.logEntry.Stdout = stdout.String()
|
||||||
|
req.logEntry.Stderr = stderr.String()
|
||||||
|
|
||||||
|
if runerr != nil {
|
||||||
|
req.logEntry.Stderr = runerr.Error() + "\n\n" + req.logEntry.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Err() == context.DeadlineExceeded {
|
if ctx.Err() == context.DeadlineExceeded {
|
||||||
req.logEntry.TimedOut = true
|
req.logEntry.TimedOut = true
|
||||||
}
|
}
|
||||||
|
|
||||||
req.logEntry.ExitCode = int32(cmd.ProcessState.ExitCode())
|
|
||||||
req.logEntry.Stdout = string(stdout)
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class ActionButton extends window.HTMLElement {
|
||||||
this.updateFromJson(json)
|
this.updateFromJson(json)
|
||||||
|
|
||||||
// DOM Attributes
|
// DOM Attributes
|
||||||
this.setAttribute("role", "none")
|
this.setAttribute('role', 'none')
|
||||||
this.btn.title = json.title
|
this.btn.title = json.title
|
||||||
this.btn.onclick = () => {
|
this.btn.onclick = () => {
|
||||||
console.log(json.arguments)
|
console.log(json.arguments)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue