[agent-go] 调通Executor的代码
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
var log = g.G.LOG
|
||||
@@ -27,11 +28,17 @@ func Execute(om *config.OctopusMessage, em *config.ExecutionMessage) ([]string,
|
||||
resultLog, err = SingleLineCommandExecutor(em.SingleLineCommand)
|
||||
}
|
||||
|
||||
// 归一化错误和日志
|
||||
if err != nil {
|
||||
resultLog = append(resultLog, fmt.Sprintf("Error: %s", err.Error()))
|
||||
}
|
||||
|
||||
// 处理执行日志
|
||||
// 是否需要返回处理日志,现在默认返回
|
||||
if em.NeedResultReplay {
|
||||
// 需要返回处理结果
|
||||
|
||||
om.ACTime = time.Now()
|
||||
om.Result = resultLog
|
||||
}
|
||||
|
||||
log.Info(fmt.Sprintf("Executor Result: %s", resultLog))
|
||||
@@ -111,6 +118,7 @@ func SingleLineCommandExecutor(singleLineCommand []string) ([]string, error) {
|
||||
var result []string
|
||||
for scanner.Scan() {
|
||||
result = append(result, scanner.Text())
|
||||
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user