Skip to content

Commit db039d0

Browse files
committed
[Fix #1180] Partially revert run task changes from #1129
Revert script arguments from array (string[]) back to object (map) to restore compatibility with the Java SDK reference implementation. Remove stdin from script process since embedded script engines (GraalJS, Jython) have no real stdin pipe — users who need stdin with scripts should use run:shell instead. Shell arguments remain as string[] since positional argv is the convention for shell commands. - Schema: revert arguments type for script to map, remove script stdin - Restore run-script-with-arguments.yaml example (map-based) - Delete run-script-with-stdin-and-arguments.yaml (argv-based) - Add run-shell-external-script.yaml showing the pattern for running an external script via shell with stdin and arguments - Update dsl-reference.md to match schema changes Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
1 parent 4d42471 commit db039d0

5 files changed

Lines changed: 53 additions & 48 deletions

File tree

dsl-reference.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,7 @@ Enables the execution of custom scripts or code within a workflow, empowering wo
981981
| language | `string` | `yes` | The language of the script to run.<br>*Supported values are: [`js`](https://tc39.es/ecma262/2024/) and [`python`](https://www.python.org/downloads/release/python-3131/).* |
982982
| code | `string` | `no` | The script's code.<br>*Required if `source` has not been set.* |
983983
| source | [externalResource](#external-resource) | `no` | The script's resource.<br>*Required if `code` has not been set.* |
984-
| stdin | `string` | `no` | A runtime expression, if any, to the script as standard input (stdin).|
985-
| arguments | `string[]` | `no` | A list of the arguments, if any, to the script as argv |
984+
| arguments | `map` | `no` | A key/value mapping of the arguments, if any, to use when running the configured script |
986985
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured script process |
987986

988987

@@ -999,21 +998,22 @@ Enables the execution of custom scripts or code within a workflow, empowering wo
999998

1000999
```yaml
10011000
document:
1002-
dsl: 1.0.3
1001+
dsl: '1.0.3'
10031002
namespace: examples
1004-
name: run-script-example
1003+
name: run-script-with-arguments
10051004
version: 1.0.0
10061005
do:
1007-
- runScript:
1006+
- setInput:
1007+
set:
1008+
message: Hello World
1009+
- log:
10081010
run:
10091011
script:
10101012
language: js
10111013
arguments:
1012-
- hello
1013-
- world
1014-
code: |
1015-
const [_, __, arg0, arg1] = process.argv;
1016-
console.log('arg > ', arg0, arg1)
1014+
message: ${ .message }
1015+
code: >
1016+
console.log(message)
10171017
```
10181018

10191019
##### Shell Process
@@ -1026,7 +1026,7 @@ Enables the execution of shell commands within a workflow, enabling workflows to
10261026
|:--|:---:|:---:|:---|
10271027
| command | `string` | `yes` | The shell command to run |
10281028
| stdin | `string` | `no` | A runtime expression, if any, to the shell command as standard input (stdin).|
1029-
| arguments | `string[]` | `no` | A list of the arguments, if any, to the shell command as argv |
1029+
| arguments | `string[]` | `no` | A list of the arguments, if any, of the shell command to run |
10301030
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process |
10311031

10321032
###### Examples
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
document:
2+
dsl: '1.0.3'
3+
namespace: examples
4+
name: run-script-with-arguments
5+
version: 1.0.0
6+
do:
7+
- setInput:
8+
set:
9+
message: Hello World
10+
- log:
11+
run:
12+
script:
13+
language: js
14+
arguments:
15+
message: ${ .message }
16+
code: >
17+
console.log(message)

examples/run-script-with-stdin-and-arguments.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
document:
2+
dsl: '1.0.3'
3+
namespace: examples
4+
name: run-shell-external-script
5+
version: 1.0.0
6+
do:
7+
- setInput:
8+
set:
9+
name: World
10+
- greet:
11+
input:
12+
from: ${ .name }
13+
run:
14+
shell:
15+
command: python3 /path/to/greet.py
16+
stdin: ${ . }
17+
arguments:
18+
- --greeting
19+
- Hello
20+
environment:
21+
LOG_LEVEL: info

schema/workflow.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,11 @@ $defs:
877877
type: string
878878
title: ScriptLanguage
879879
description: The language of the script to run.
880-
stdin:
881-
type: string
882-
title: ScriptStdin
883-
description: A runtime expression, if any, to the script as standard input (stdin).
884880
arguments:
885-
type: array
881+
type: object
886882
title: ScriptArguments
887-
description: A list of the arguments, if any, to the script as argv
888-
items:
889-
type: string
883+
description: A key/value mapping of the arguments, if any, to use when running the configured script.
884+
additionalProperties: true
890885
environment:
891886
type: object
892887
title: ScriptEnvironment
@@ -931,7 +926,7 @@ $defs:
931926
arguments:
932927
type: array
933928
title: ShellArguments
934-
description: A list of the arguments, if any, to the shell command as argv
929+
description: A list of the arguments, if any, of the shell command to run.
935930
items:
936931
type: string
937932
environment:

0 commit comments

Comments
 (0)