|
|
@@ -1238,8 +1238,22 @@ func stepExecAfter(req *ExecutionRequest) bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
-func buildShellAfterCommand(ctx context.Context, req *ExecutionRequest, stdout, stderr *bytes.Buffer) (*exec.Cmd, map[string]string, error) {
|
|
|
+func shellAfterCompletedAction(req *ExecutionRequest) (*config.Action, bool) {
|
|
|
+ if req == nil {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ if !hasBindingAndAction(req) {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
if req.Binding.Action.ShellAfterCompleted == "" {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ return req.Binding.Action, true
|
|
|
+}
|
|
|
+
|
|
|
+func buildShellAfterCommand(ctx context.Context, req *ExecutionRequest, stdout, stderr *bytes.Buffer) (*exec.Cmd, map[string]string, error) {
|
|
|
+ action, ok := shellAfterCompletedAction(req)
|
|
|
+ if !ok {
|
|
|
return nil, nil, nil
|
|
|
}
|
|
|
|
|
|
@@ -1248,14 +1262,14 @@ func buildShellAfterCommand(ctx context.Context, req *ExecutionRequest, stdout,
|
|
|
return nil, nil, err
|
|
|
}
|
|
|
|
|
|
- finalParsedCommand, err := tpl.ParseTemplateWithActionContext(req.Binding.Action.ShellAfterCompleted, req.Binding.Entity, args)
|
|
|
+ finalParsedCommand, err := tpl.ParseTemplateWithActionContext(action.ShellAfterCompleted, req.Binding.Entity, args)
|
|
|
if err != nil {
|
|
|
msg := "Could not prepare shellAfterCompleted command: " + err.Error() + "\n"
|
|
|
req.mutateLogEntry(func(entry *InternalLogEntry) {
|
|
|
entry.Output += msg
|
|
|
})
|
|
|
log.Warn(msg)
|
|
|
- return nil, nil, nil
|
|
|
+ return nil, nil, err
|
|
|
}
|
|
|
|
|
|
cmd := wrapCommandInShell(ctx, finalParsedCommand)
|