From aee910c1f89d67afb1d001916a633376b0825a81 Mon Sep 17 00:00:00 2001 From: mrhid6 Date: Mon, 20 Jul 2026 18:00:47 +0100 Subject: [PATCH] fix: fixed variable inputs --- server/internal/services/workflow_runner.go | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/server/internal/services/workflow_runner.go b/server/internal/services/workflow_runner.go index c9155c1..1a62160 100644 --- a/server/internal/services/workflow_runner.go +++ b/server/internal/services/workflow_runner.go @@ -2,6 +2,7 @@ package services import ( "fmt" + "os" "strings" "time" @@ -188,9 +189,19 @@ func runServer(runID string, srvIdx int, steps []models.ResolvedStep, serverID s for k, v := range secretVals { allSecrets[k] = v } + // Input values may template earlier step outputs and secrets, e.g. + // URL="http://example.com/$VersionNumber". Expand against runEnv (outputs + // threaded from prior steps) and this step's secrets before dispatch. + subst := map[string]string{} + for k, v := range runEnv { + subst[k] = v + } + for k, v := range secretVals { + subst[k] = v + } cmdEnv := map[string]string{} for k, v := range step.Inputs { - cmdEnv[k] = v + cmdEnv[k] = expandVars(v, subst) } for k, v := range runEnv { cmdEnv[k] = v @@ -310,6 +321,18 @@ func dispatchAndWait(serverID, commandID string, cmd *pb.RunStepCmd) *pb.StepRes } } +// expandVars substitutes $VAR and ${VAR} references in an input value from the +// given lookup (prior step outputs and secrets). Unknown references expand to +// empty, matching shell behaviour; a literal "$" is written as "$$". +func expandVars(v string, lookup map[string]string) string { + return os.Expand(v, func(name string) string { + if name == "$" { + return "$" + } + return lookup[name] + }) +} + func resolveSecrets(refs []string) map[string]string { out := map[string]string{} for _, ref := range refs {