Skip to content

Commit 4a1d770

Browse files
committed
slurmCI: Fix matrix variable resolution
- Change resolveTemplate call to pass env directly instead of ['env': env] to enable resolution of matrix variables like ${arch} from the environment. - Add debug output to print original and resolved arg values for easier troubleshooting of template resolution issues. Signed-off-by: Daniel Pressler <danielpr@nvidia.com>
1 parent 839904f commit 4a1d770

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

vars/slurmCI.groovy

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,26 @@ int call(ctx, oneStep, config) {
2121
}
2222

2323
for (def entry in ctx.entrySet(args)) {
24-
args[entry.key] = ctx.resolveTemplate(['env': env], entry.value.toString(), config)
24+
def original = entry.value.toString()
25+
def resolved = ctx.resolveTemplate(['env': env], original, config)
26+
// resolveTemplate is @NonCPS and cannot see withEnv-set axis vars (e.g. ucx_version, arch)
27+
// via env.getEnvironment(). Do a second pass here in CPS context where env property
28+
// access DOES include withEnv vars.
29+
def pass2 = resolved
30+
def safety = 0
31+
while (pass2.contains('${') && safety++ < 20) {
32+
def start = pass2.indexOf('${')
33+
def end = pass2.indexOf('}', start)
34+
if (end == -1) break
35+
def varName = pass2.substring(start + 2, end)
36+
def val = env."${varName}"
37+
if (val != null) {
38+
pass2 = pass2.substring(0, start) + val + pass2.substring(end + 1)
39+
} else {
40+
break
41+
}
42+
}
43+
args[entry.key] = pass2
2544
}
2645
def stepRun = oneStep.run
2746
def allowedOps = ['allocation', 'run', 'stop', 'stopAllForBuild'] as Set

0 commit comments

Comments
 (0)