[agent-go] 调通Executor的代码

This commit is contained in:
zeaslity
2023-03-27 16:06:33 +08:00
parent 5accd999f8
commit 31f9267401
9 changed files with 124 additions and 54 deletions

View File

@@ -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 {