From 5f051969150fefb794c679a36eb81dd64e40cc85 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 6 Apr 2024 19:54:53 +0000 Subject: [PATCH] Add vars context to cron jobs (#3059) Introduce vars context into cron triggered actions Fixes #3044 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3059 Reviewed-by: Earl Warren Co-authored-by: TheFox0x7 Co-committed-by: TheFox0x7 --- services/actions/schedule_tasks.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/actions/schedule_tasks.go b/services/actions/schedule_tasks.go index 59862fd0d8..5a9ff16fb6 100644 --- a/services/actions/schedule_tasks.go +++ b/services/actions/schedule_tasks.go @@ -127,8 +127,17 @@ func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule) Status: actions_model.StatusWaiting, } + if err := run.LoadAttributes(ctx); err != nil { + log.Error("LoadAttributes: %v", err) + } + + vars, err := actions_model.GetVariablesOfRun(ctx, run) + if err != nil { + log.Error("GetVariablesOfSchedule: %v", err) + } + // Parse the workflow specification from the cron schedule - workflows, err := jobparser.Parse(cron.Content) + workflows, err := jobparser.Parse(cron.Content, jobparser.WithVars(vars)) if err != nil { return err }