Stage
A stage is considered as an atomic runnable
unit. Multiple stages may be executed
concurrently.
A stage can accept a script, a command and a set of arguments, or a macro.
Stage with Script
togomak {
version = 2
}
stage "script" {
script = "echo 'Hello World'"
}
Stage with Command and Arguments
togomak {
version = 2
}
stage "command" {
args = ["echo", "Hello World"]
}
Stage with Macro
togomak {
version = 2
}
macro "echo" {
stage "echo" {
args = ["echo", "Hello World"]
}
}
stage "macro" {
use {
macro = macro.echo
}
}
Stage with Dependencies
togomak {
version = 2
}
stage "build" {
script = "echo 'Building'"
}
stage "install" {
depends_on = [stage.build]
script = "echo 'Installing'"
}
Stage with Retry
togomak {
version = 2
}
stage "build" {
script = <<-EOT
echo this script will fail
exit 1
EOT
retry {
enabled = true
attempts = 3
exponential_backoff = true
min_backoff = 1
max_backoff = 10
}
}
Stage with Containers
togomak {
version = 2
}
stage "example" {
container {
image = "ubuntu"
volume {
source = "${cwd}/diary"
destination = "/newdiary"
}
}
script = <<-EOT
#!/usr/bin/env bash
ls -al
for i in $(seq 1 10); do
sleep 1
echo "Loading $i..."
done
cat rei.diary.txt
ls -al /newdiary
EOT
}
Arguments Reference
-
name- The name of the stage -
if- The condition to be evaluated before running the stage -
use- Macro, or a provider that could be used. Structure is documented below -
depends_on- The stages which this stage depends on. -
container- The container to be used to run the stage. Structure is documented below -
script- The script to be executed -
args- The command and arguments to be executed -
retry- Stage retry configuration. Structure is documented below -
daemon- Daemon specific configuration. Structure is documented below
macro- The macro to be used
enabled- Whether the stage should be retried, defaults tofalseattempts- The number of times the stage should be retriedexponential_backoff- Whether the backoff should be exponentialmin_backoff- The minimum backoff time (in seconds)max_backoff- The maximum backoff time (in seconds)
image- The container image to be used
Daemonization is still wip, see daemonization for more information on availability
The daemon block supports:
enabled- Whether the stage should be run as a daemon, defaults tofalsetimeout- Time to wait until the stage is terminated, in seconds. Defaults to 0 (no timeout).lifecycle- Set of rules which decide if the daemon needs to be terminated, or not. Structure documented below
- [
stop_when_complete] - Array of stages.togomakwaits for all the stages mentioned in thestop_when_completeargument, before sendingSIGTERMto the daemon process