feat(cli): variable expansion, scalar bool/int support, precedence fix
ci / vet, staticcheck, test, build (push) Successful in 2m15s
release / Build and publish release (push) Successful in 1m13s

- Add $VAR / ${VAR} expansion in effective context (ctx.ExpandVars):
  iterates up to 10 passes to resolve transitive chains; circular
  references are left as-is after the limit.
- Handle non-string YAML scalars (bool, int, float64) in
  ExtractStringVars and varValueString via new ScalarString helper;
  values like BUILD: true no longer render as "(complex)" or get
  silently dropped from the effective context.
- Variable precedence (GitLab spec): pipeline defaults < workflow-rule
  vars < CLI --var flags; implemented correctly in enrichContext;
  expansion applied after all sources are merged.
- Update README, CHANGELOG, ROADMAP for v0.2.13.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 12:32:47 +02:00
parent 1339ab4149
commit cbed44b1e9
5 changed files with 147 additions and 21 deletions
+5 -8
View File
@@ -404,14 +404,8 @@ func printVarMap(m map[string]any) {
}
func varValueString(v any) string {
switch val := v.(type) {
case string:
return val
case map[string]any:
if s, ok := val["value"].(string); ok {
return s
}
return "(complex)"
if s, ok := cicontext.ScalarString(v); ok {
return s
}
return "(complex)"
}
@@ -432,6 +426,9 @@ func enrichContext(ctx *cicontext.Context, p *model.Pipeline) {
for k, v := range ruleVars {
ctx.Inject(k, v)
}
// Expand $VAR / ${VAR} references within variable values now that all
// sources (pipeline, workflow rules, CLI) have been merged.
ctx.ExpandVars()
}
func printContext(p *model.Pipeline, ctx *cicontext.Context) {