35
loading...
This website collects cookies to deliver better user experience
$ python3 -mvenv venv
$ source venv/bin/activate
$ pip install -U runflow
.hcl
file. This is a file in HCL2 syntax and follow the Flow spec. # File: hello_world.hcl
flow "hello_world" {
task "bash_run" "echo" {
command = "echo hello world"
}
}
echo hello world
.runflow run
:$ runflow run hello_world.hcl
[2021-07-02 23:24:33,550] "task.bash_run.echo" is started.
hello world
[2021-07-02 23:24:33,561] "task.bash_run.echo" is successful.
# File: hello_vars.hcl
flow "hello_vars" {
variable "greeter" {
default = "world"
}
task "bash_run" "echo" {
command = "echo 'hello ${var.greeter}'"
}
}
--var
and --var-file
.# use default variable
$ runflow run hello_vars.hcl
[2021-07-02 23:28:01,686] "task.bash_run.echo" is started.
hello world
[2021-07-02 23:28:01,696] "task.bash_run.echo" is successful.
# use `--var`
$ runflow run hello_vars.hcl --var greeter=世界
[2021-07-02 23:28:39,351] "task.bash_run.echo" is started.
hello 世界
[2021-07-02 23:28:39,359] "task.bash_run.echo" is successful.
# use `--var-file`
$ cat vars.hcl
greeter = "WORLD"
$ runflow run hello_vars.hcl --var-file=vars.hcl
[2021-07-02 23:29:31,314] "task.bash_run.echo" is started.
hello WORLD
[2021-07-02 23:29:31,322] "task.bash_run.echo" is successful.
"file_read"
, "file_write"
. The task type supports reading file not only from local file system, but also from a zip archive, a Git repo, a GitHub project, FTP server, etc."http_request"
."sql_exec"
, "sql_row"
. The task type supports running SQL commands on SQLite, MySQL, MSSQL, PostgreSQL, etc."bash_run"
."docker_run"
."flow_run"
. This allows modularize your workflows.${task.TASK_TYPE.TASK_NAME.ATTRIBUTE}
.flow "hello-implicit-deps" {
task "bash_run" "task2" {
command = "echo 'hello ${task.bash_run.greeter.stdout}'"
}
task "bash_run" "task1" {
command = "xxd -l16 -ps /dev/urandom"
}
}
_depends_on
argument so the task is checked first before running. Only when all values in _depends_on
list is truthy, the task will run.task.file_write.echo
only when the given version is >= 0.6.0.flow "conditional_trigger" {
variable "version" {
default = "0.6.0"
}
task "file_read" "read" {
filename = "pyproject.toml"
}
task "file_write" "echo" {
filename = "/dev/stdout"
content = task.file_read.read.content
_depends_on = [
var.version >= "0.6.0"
]
}
}
_retry
.task "http_request" "fetch" {
method = "GET"
url = var.url
_retry = {
stop_after = "3 times | 10 seconds"
wait = wait_fixed(1)
}
}