mirror of
https://github.com/go-task/task.git
synced 2026-07-09 06:55:14 +00:00
✨ feat(output): add gitlab output mode (#2806)
Adds a new `gitlab` output style that wraps each task's output in GitLab CI collapsible section markers. Section IDs are generated automatically so that start and end markers always match and stay unique per invocation — even when the same task runs multiple times in one job. Options: `collapsed` (maps to GitLab's native `[collapsed=true]`) and `error_only` (Task-level behavior, identical to `group.error_only`). Also introduces `output-ci-auto` (taskrc + TASK_OUTPUT_CI_AUTO env var) that auto-selects a CI-aware output style when a supported CI runner is detected (currently `GITLAB_CI=true` → gitlab) and no output style is explicitly configured. Keeps the Taskfile neutral so local devs are not forced into CI-shaped output. Refs #2806.
This commit is contained in:
16
setup.go
16
setup.go
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -202,12 +203,27 @@ func (e *Executor) setupOutput() error {
|
||||
if !e.OutputStyle.IsSet() {
|
||||
e.OutputStyle = e.Taskfile.Output
|
||||
}
|
||||
if !e.OutputStyle.IsSet() && e.OutputCIAuto {
|
||||
if name := detectCIOutput(); name != "" {
|
||||
e.OutputStyle.Name = name
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
e.Output, err = output.BuildFor(&e.OutputStyle, e.Logger)
|
||||
return err
|
||||
}
|
||||
|
||||
// detectCIOutput returns the name of a CI-aware output style to use based
|
||||
// on environment variables set by common CI runners. Returns an empty string
|
||||
// when no supported CI environment is detected.
|
||||
func detectCIOutput() string {
|
||||
if isGitLab, _ := strconv.ParseBool(os.Getenv("GITLAB_CI")); isGitLab {
|
||||
return "gitlab"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (e *Executor) setupCompiler() error {
|
||||
if e.UserWorkingDir == "" {
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user