Skip to content

Commit 706d93d

Browse files
authored
fix(tasks): inject outputFiles into Pebble context in CommandsWrapper.render() (#15758)
The run() method already built the outputFiles map for renderCommands(), but render(RunContext, Property<String>) called from Script.run() used only taskRunner.additionalVars() — no outputFiles — so {{ outputFiles.name }} resolved at script render time with "Unable to find `outputFiles`". Apply the same non-glob name→workingDir/name injection in render() so the variable is available before run() is called. Fixes #13765
1 parent 5c03321 commit 706d93d

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

script/src/main/java/io/kestra/plugin/scripts/exec/scripts/runners/CommandsWrapper.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,21 @@ public String render(RunContext runContext, Property<String> command) throws Ill
265265
return null;
266266
}
267267

268-
return runContext.render(command).as(String.class, taskRunner.additionalVars(runContext, this))
268+
Map<String, Object> additionalVars = taskRunner.additionalVars(runContext, this);
269+
if (this.outputFiles != null && !this.outputFiles.isEmpty()) {
270+
String workingDir = String.valueOf(additionalVars.getOrDefault(ScriptService.VAR_WORKING_DIR, this.workingDirectory));
271+
Map<String, String> outputFilesMap = new LinkedHashMap<>();
272+
for (String name : this.outputFiles) {
273+
if (!name.contains("*") && !name.contains("?") && !name.contains("[")) {
274+
outputFilesMap.put(name, workingDir + "/" + name);
275+
}
276+
}
277+
if (!outputFilesMap.isEmpty()) {
278+
additionalVars.put("outputFiles", outputFilesMap);
279+
}
280+
}
281+
282+
return runContext.render(command).as(String.class, additionalVars)
269283
.map(throwFunction(c -> ScriptService.replaceInternalStorage(runContext, c, taskRunner instanceof RemoteRunnerInterface)))
270284
.orElse(null);
271285
}

0 commit comments

Comments
 (0)