Options
All
  • Public
  • Public/Protected
  • All
Menu

A Brigade job.

Instances of Job represent containers that your Brigade script can run using the Job#run method.

The Job#primaryContainer, initialized from the constructor image argument, determines how long the job runs and whether it is considered successful. By default, the container is simply executed (via its default entry point). Set the Job#primaryContainer#command property to run a specific command in the container instead. Other containers, specified via Job#sidecarContainers, are automatically terminated a short time after the primary container completes.

Job also provides static methods for building up runnable elements out of more basic ones. For example, to compose a set of workloads into a sequence, you can use the Job.sequence method.

Hierarchy

  • Job

Implements

Index

Constructors

  • new Job(name: string, image: string, event: Event): Job
  • Constructs a new Job.

    Parameters

    • name: string

      The name of the job

    • image: string

      The OCI image reference for the primary container

    • event: Event

      The event that triggered the job

    Returns Job

Properties

event: Event

The event that triggered the job.

fallible: boolean = false

Specifies whether the job is permitted to fail WITHOUT causing the worker process to fail.

host: JobHost = ...

Specifies requirements for the job execution environment.

name: string

The name of the job.

primaryContainer: Container

Provides configuration options for the job's primary container.

sidecarContainers: {} = {}

Specifies sidecar containers to run alongside the primary container.

Type declaration

timeoutSeconds: number = defaultTimeoutSeconds

The duration, in seconds, after which Brigade should automatically terminate and fail the job if it has not completed. The default is 15 minutes.

Methods

  • logs(): Promise<string>
  • Gets the job logs.

    If the job has multiple containers, this aggregates the logs from them all.

    NOTE: In a local test environment, this function returns a dummy log. In the real Brigade runtime environment, it returns the actual container logs.

    Returns Promise<string>

  • run(): Promise<void>
  • Runs the job.

    When you run the job, Brigade runs all the containers, primary and sidecar. When the primary container exits, the job ends. If sidecars are still running at this point, Brigade terminates them after a short delay.

    NOTE: In a local test environment, this function does not run the containers, but instead automatically succeeds. In the real Brigade runtime environment, the containers run as described.

    Returns Promise<void>

    A Promise which completes when the primary container completes. If the primary container succeeded (exited with code 0), the Promise resolves; if the primary container failed (exited with nonzero code) or timed out, the Promise rejects. Sidecars do not affect success or failure of the job.

  • Specifies a Runnable composed of sub-Runnables (such as jobs or sequential groups) running concurrently. When run, all Runnables are started simultaneously (subject to scheduling constraints). The concurrent group completes when all Runnables have completed.

    Parameters

    • Rest ...runnables: Runnable[]

      The work items to be run in parallel

    Returns ConcurrentGroup

  • container(name: string, image: string, event: Event): Job
  • Specifies a Runnable that executes one or more containers. The image argument specifies the primary container, which determines how long the job runs and whether it is considered successful. By default, the primary container is simply executed (via its default entry point). Set the Job#primaryContainer#command property to run a specific command in the container instead. Other containers, specified via Job#sidecarContainers, are automatically terminated after the primary container completes.

    (Note: This is equivalent to new Job(...). It is provided so that script authors have the option of a consistent style for creating and composing jobs and groups.)

    Parameters

    • name: string

      The name of the job

    • image: string

      The OCI image reference for the primary container

    • event: Event

      The event that triggered the job

    Returns Job

  • Specifies a Runnable composed of sub-Runnables (such as jobs or concurrent groups) running one after another. A new Runnable is started only when the previous one completes. The sequence completes when the last Runnable has completed (or when any Runnable fails).

    Parameters

    • Rest ...runnables: Runnable[]

      The work items to be run in sequence

    Returns SerialGroup

Generated using TypeDoc