(t *ast.Task, call *Call, i int, vars *ast.Vars, deferredExitCode *uint8)
| 338 | } |
| 339 | |
| 340 | func (e *Executor) runDeferred(t *ast.Task, call *Call, i int, vars *ast.Vars, deferredExitCode *uint8) { |
| 341 | ctx, cancel := context.WithCancel(context.Background()) |
| 342 | defer cancel() |
| 343 | |
| 344 | cmd := t.Cmds[i] |
| 345 | cache := &templater.Cache{Vars: vars} |
| 346 | extra := map[string]any{} |
| 347 | |
| 348 | if deferredExitCode != nil && *deferredExitCode > 0 { |
| 349 | extra["EXIT_CODE"] = fmt.Sprintf("%d", *deferredExitCode) |
| 350 | } |
| 351 | |
| 352 | // Resolve template with secrets masked for logging |
| 353 | cmd.LogCmd = templater.MaskSecretsWithExtra(cmd.Cmd, vars, extra) |
| 354 | cmd.Cmd = templater.ReplaceWithExtra(cmd.Cmd, cache, extra) |
| 355 | cmd.Task = templater.ReplaceWithExtra(cmd.Task, cache, extra) |
| 356 | cmd.If = templater.ReplaceWithExtra(cmd.If, cache, extra) |
| 357 | cmd.Vars = templater.ReplaceVarsWithExtra(cmd.Vars, cache, extra) |
| 358 | |
| 359 | if err := e.runCommand(ctx, t, call, i); err != nil { |
| 360 | e.Logger.VerboseErrf(logger.Yellow, "task: ignored error in deferred cmd: %s\n", err.Error()) |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | func (e *Executor) runCommand(ctx context.Context, t *ast.Task, call *Call, i int) error { |
| 365 | cmd := t.Cmds[i] |
no test coverage detected