diff --git a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java index 746a49e..d007067 100644 --- a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java +++ b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java @@ -51,9 +51,12 @@ @Example( title = "Execute Shell commands that generate files accessible by other tasks and available for download in the UI's Output tab.", code = { + "outputFiles:", + " - first.txt", + " - second.txt", "commands:", - " - echo \"1\" >> {{ outputDir }}/first.txt", - " - echo \"2\" >> {{ outputDir }}/second.txt" + " - echo \"1\" >> first.txt", + " - echo \"2\" >> second.txt" } ), @Example( diff --git a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java index 1efcb93..947349a 100644 --- a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java +++ b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java @@ -28,12 +28,22 @@ examples = { @Example( title = "Create an inline Shell script and execute it.", - code = { - "script: |", - " echo \"The current execution is : {{ execution.id }}\"", - " echo \"1\" >> {{ outputDir }}/first.txt", - " cat {{ outputs.previousTaskId.uri }}" - } + full = true, + code = """ + id: shell_script_example + namespace: company.team + tasks: + - id: http_download + type: io.kestra.plugin.core.http.Download + uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv + - id: shell_script_task + type: io.kestra.plugin.scripts.shell.Script + outputFiles: + - first.txt + script: | + echo "The current execution is : {{ execution.id }}" + echo "1" >> first.txt + cat {{ outputs.http_download.uri }}""" ), @Example( full = true, @@ -41,15 +51,17 @@ If you want to generate files in your script to make them available for download and use in downstream tasks, you can leverage the `{{ outputDir }}` variable. Files stored in that directory will be persisted in Kestra's internal storage. To access this output in downstream tasks, use the syntax `{{ outputs.yourTaskId.outputFiles['yourFileName.fileExtension'] }}`. """, code = """ - id: shell + id: shell_script_example namespace: company.team tasks: - id: hello type: io.kestra.plugin.scripts.shell.Script taskRunner: type: io.kestra.plugin.core.runner.Process + outputFiles: + - hello.txt script: | - echo "Hello world!" > {{ outputDir }}/hello.txt""" + echo "Hello world!" > hello.txt""" ) } )