From ebe06f27c09e09e272d6a581a02c5d7170a03beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Mon, 5 Aug 2024 18:11:18 +0200 Subject: [PATCH] fix(plugin-sript): bash task cannot run with a volume Because it creates locally directory. --- .../io/kestra/core/tasks/scripts/AbstractBash.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin-script/src/main/java/io/kestra/core/tasks/scripts/AbstractBash.java b/plugin-script/src/main/java/io/kestra/core/tasks/scripts/AbstractBash.java index 0b703a2..2a43e9a 100644 --- a/plugin-script/src/main/java/io/kestra/core/tasks/scripts/AbstractBash.java +++ b/plugin-script/src/main/java/io/kestra/core/tasks/scripts/AbstractBash.java @@ -6,10 +6,12 @@ import io.kestra.core.models.tasks.runners.PluginUtilsService; import io.kestra.core.models.tasks.runners.ScriptService; import io.kestra.core.runners.RunContext; +import io.kestra.plugin.core.runner.Process; import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions; import io.kestra.plugin.scripts.exec.scripts.models.RunnerType; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; 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.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; @@ -226,11 +228,15 @@ protected io.kestra.core.tasks.scripts.ScriptOutput run(RunContext runContext, S commandsSupplier.get() ); + var taskRunner = switch (this.runner) { + case DOCKER -> Docker.from(this.getDockerOptions()).toBuilder().fileHandlingStrategy(Docker.FileHandlingStrategy.MOUNT).build(); + case PROCESS -> Process.INSTANCE; + }; + ScriptOutput run = new CommandsWrapper(runContext) .withEnv(this.finalEnv()) .withWarningOnStdErr(this.warningOnStdErr) - .withRunnerType(this.runner) - .withDockerOptions(this.getDockerOptions()) + .withTaskRunner(taskRunner) .withCommands(commandsArgs) .addAdditionalVars(this.additionalVars) .run();