mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
fix(script): targetOS must be rendered
This commit is contained in:
@@ -15,7 +15,6 @@ import io.kestra.plugin.scripts.exec.scripts.runners.CommandsWrapper;
|
||||
import io.kestra.plugin.scripts.runner.docker.Docker;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
@@ -106,6 +105,7 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
|
||||
title = "The target operating system where the script will run."
|
||||
)
|
||||
@Builder.Default
|
||||
@NotNull
|
||||
protected Property<TargetOS> targetOS = Property.of(TargetOS.AUTO);
|
||||
|
||||
@Schema(
|
||||
@@ -179,11 +179,11 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
|
||||
}
|
||||
|
||||
if (commands == null || commands.isEmpty()) {
|
||||
return getExitOnErrorCommands();
|
||||
return getExitOnErrorCommands(runContext);
|
||||
}
|
||||
|
||||
ArrayList<String> newCommands = new ArrayList<>(commands.size() + 1);
|
||||
newCommands.addAll(getExitOnErrorCommands());
|
||||
newCommands.addAll(getExitOnErrorCommands(runContext));
|
||||
newCommands.addAll(commands);
|
||||
return newCommands;
|
||||
}
|
||||
@@ -192,9 +192,12 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
|
||||
* Gets the list of additional commands to be used for defining interpreter errors handling.
|
||||
* @return list of commands;
|
||||
*/
|
||||
protected List<String> getExitOnErrorCommands() {
|
||||
protected List<String> getExitOnErrorCommands(RunContext runContext) throws IllegalVariableEvaluationException {
|
||||
TargetOS rendered = runContext.render(this.getTargetOS()).as(TargetOS.class).orElseThrow();
|
||||
|
||||
// If targetOS is Windows OR targetOS is AUTO && current system is windows and we use process as a runner.(TLDR will run on windows)
|
||||
if (this.getTargetOS().equals(TargetOS.WINDOWS) || this.getTargetOS().equals(TargetOS.AUTO) && SystemUtils.IS_OS_WINDOWS && this.getTaskRunner() instanceof Process) {
|
||||
if (rendered == TargetOS.WINDOWS ||
|
||||
(rendered == TargetOS.AUTO && SystemUtils.IS_OS_WINDOWS && this.getTaskRunner() instanceof Process)) {
|
||||
return List.of("");
|
||||
}
|
||||
// errexit option may be unsupported by non-shell interpreter.
|
||||
|
||||
Reference in New Issue
Block a user