Skip to content

feat(notifier): gitlab_artifact notifier (Wave 1 Tier-2 #1) - #11

Merged
zuchka merged 2 commits into
mainfrom
add-gitlab-artifact-notifier
May 7, 2026
Merged

zuchka merged 2 commits into
mainfrom
add-gitlab-artifact-notifier

Conversation

@zuchka

@zuchka zuchka commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a built-in `type: gitlab_artifact` notifier that writes alert Markdown to a configurable file path (default `ding-alerts.md`, relative to `$CI_PROJECT_DIR`), so GitLab CI users can declare it in `.gitlab-ci.yml` `artifacts:` and surface alerts as a downloadable pipeline artifact in the GitLab UI. Closes the gap flagged in the GitLab CI recipe — first row of the Wave 1 Tier-2 candidates table marked shipped.

This continues the established Tier-2 cadence: T2-A (`${VAR}`), T2-B (`kubernetes_event` shipped in v0.9.0), and now Wave 1 #1 (`gitlab_artifact`).

Design (locked in brainstorm)

  • Format: Markdown only (mirrors GHA notifier shape). No `format:` config field.
  • Path: optional `path:` field; defaults to `ding-alerts.md` in CWD. Multiple notifier instances → multiple files.
  • Pattern: sync, mutex-guarded, append-only. Mirrors `internal/notifier/github_actions.go` exactly minus the `::warning::` stdout mirror (GitLab CI lacks workflow-annotation commands).
  • No CI gate: writes the file regardless of whether running in GitLab CI. Outside CI, it just makes a local file — harmless.
  • No async queue / retry / metrics: sync local file write; nothing to instrument.

Commits

  1. `feat(notifier): gitlab_artifact notifier (sync Markdown append)` — impl + 7 tests + 1 new field on `NotifierConfig` + config + server registry wiring (303 insertions, no new deps)
  2. `docs(recipes): document gitlab_artifact notifier` — recipe positive section, configuration.md entry, ding.yaml.example block

Test plan

  • `go test -race ./...` — full suite green
  • `go test -race ./internal/notifier/... -run TestGitLabArtifact -v` — all 7 new tests pass
  • `go build -o /tmp/ding ./cmd/ding && /tmp/ding --help` — binary builds
  • Local smoke (light, no real GitLab CI required):
    ```bash
    mkdir /tmp/gitlab-artifact-smoke && cd /tmp/gitlab-artifact-smoke
    cat > ding.yaml <<'YAML'
    notifiers:
    alerts:
    type: gitlab_artifact
    rules:
    • name: job_failed
      match: { metric: run.exit }
      condition: value > 0
      message: "Job failed (exit {{ .exit_code }})"
      alert:
      • notifier: alerts
        YAML
        /tmp/ding run --config ding.yaml -- false
        cat ding-alerts.md

    Expected: file with "# DING Alerts" header + "## job_failed" section

    ```
  • mkdocs build --strict (CI runs it; not run locally if mkdocs isn't installed)

Out of scope (deferred)

  • `format: json | jsonl | plain` field — Markdown only for v1
  • `artifacts:reports:*` integration — repurposes report schemas; complexity > value
  • Generic `markdown_file` notifier — keep `gitlab_artifact` per Wave 1 spec naming
  • Path safety guards — YAGNI

Post-merge

By the established convention (MLflow → v0.6.0, Argo → v0.7.0, Ray → v0.8.0, kubernetes_event → v0.9.0), this could tag as v0.10.0 if you want the new notifier in a release rather than just on main.

🤖 Generated with Claude Code

zuchka and others added 2 commits May 7, 2026 10:52
Adds a built-in `type: gitlab_artifact` notifier that writes alert
Markdown to a configurable file path (default ding-alerts.md, relative
to CWD = $CI_PROJECT_DIR in GitLab CI). Users declare the path in
their .gitlab-ci.yml `artifacts:` block to surface alerts as a
downloadable/browsable pipeline artifact, closing the "no native
step-summary surface" gap documented in the GitLab CI recipe.

Pattern: sync, mutex-guarded, append-only. Mirrors github_actions.go
shape exactly minus the ::warning:: stdout mirror (GitLab CI lacks
workflow-annotation commands; users add type: stdout alongside if
they want runtime visibility).

No new dependencies, no go.mod changes. Single optional `path:`
field added to NotifierConfig. 7 unit tests cover header behavior,
multi-alert append, default path, file write errors, label sort
stability, empty message handling, and concurrent Send serialization.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- docs/recipes/gitlab-ci.md: replace the "no native step-summary
  surface" gotcha with a positive `## Native GitLab UI surfacing`
  section showing the new notifier + .gitlab-ci.yml `artifacts:`
  declaration. Update Escalation criteria gotcha count (2 → 1)
  and reframe the Tier-2 trigger as fulfilled.
- docs/configuration.md: new `### type: gitlab_artifact` section
  in the Notifiers chapter, between kubernetes_event and webhook.
- ding.yaml.example: commented example block in the notifiers
  catalog after the kubernetes_event entry.

Closes the documented gap from Wave 1 review (the recipe's
prior line 86 trigger has fired). After this commit, type:
gitlab_artifact is a fully-documented built-in notifier.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zuchka
zuchka merged commit 6b848e8 into main May 7, 2026
1 check passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant