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


The use block supports:

  • macro - The macro to be used

The retry block supports:

  • enabled - Whether the stage should be retried, defaults to false
  • attempts - The number of times the stage should be retried
  • exponential_backoff - Whether the backoff should be exponential
  • min_backoff - The minimum backoff time (in seconds)
  • max_backoff - The maximum backoff time (in seconds)

The container block supports:

  • 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 to false
  • timeout - 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. togomak waits for all the stages mentioned in the stop_when_complete argument, before sending SIGTERM to the daemon process