Skip to content

Allow configuring --output / --output-group-begin / --output-group-end via environment variables #2872

@liiight

Description

@liiight

Description

Description

Task supports environment-variable equivalents for several CLI flags (for example TASK_VERBOSE=1 enables verbose mode, the same as --verbose). However, there is no environment-variable equivalent for the output-related flags:

  • --output (-o)
  • --output-group-begin
  • --output-group-end
  • --output-group-error-only

These can currently only be set as CLI flags on the task invocation, or as the static output: key in a Taskfile.

Motivation / use case

In a CI pipeline (GitLab CI in our case), we want grouped output with custom begin/end markers so each task's output renders as a collapsible job-log section. The two existing ways to enable this both have drawbacks:

  1. output: in the Taskfile is global and unconditional. It also affects local runs and, critically, corrupts values captured from sh: task ... dynamic variables, because the grouped output wrapping is applied to the captured stdout. So we cannot safely set it in the Taskfile.

  2. CLI flags (task -o group --output-group-begin=... --output-group-end=...) work and are scoped to the invocation, but they must be added to every task call across the CI configuration. In a large pipeline with dozens of task invocations across many job templates, this is repetitive and error-prone, and easy to forget on new jobs.

An environment variable (e.g. TASK_OUTPUT, TASK_OUTPUT_GROUP_BEGIN, TASK_OUTPUT_GROUP_END, TASK_OUTPUT_GROUP_ERROR_ONLY) would let us enable CI-friendly grouped output once at the pipeline/job level (a single variables: entry) without touching the Taskfile or every invocation. This keeps local runs clean (no env var set) while turning on grouping everywhere in CI.

Current behavior (Task 3.50.0)

$ TASK_VERBOSE=1 task        # works: verbose mode enabled via env var
task: "default" started
...

$ TASK_OUTPUT=group task     # ignored: no grouping applied
... plain output ...

Proposed behavior

Recognize environment variables mirroring the flags, with the usual precedence (CLI flag > env var > Taskfile output: > default). Suggested names, consistent with the existing TASK_* convention:

Flag Proposed env var
--output TASK_OUTPUT
--output-group-begin TASK_OUTPUT_GROUP_BEGIN
--output-group-end TASK_OUTPUT_GROUP_END
--output-group-error-only TASK_OUTPUT_GROUP_ERROR_ONLY

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions