Set Up Slack Alerts for Job Results

How to set up alerting to Slack for a CI job.

We can set up Slack alerts for job results by configuring the reporter_config field on individual tests in the ci-operator configuration file. This is possible for all job types: periodics, presubmits, and postsubmits.

Setting up Slack notifications

To add Slack reporting for a test, add the reporter_config field to the test in your ci-operator configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
tests:
- as: "unit"
  commands: "make test-unit"
  container:
    from: "bin"
  reporter_config:
    channel: "#my-channel"
    job_states_to_report:
    - failure
    - error
    report_template: 'Job {{.Spec.Job}} ended with {{.Status.State}}. <{{.Status.URL}}|View logs>'

Configuration fields

  • channel (required) The Slack channel to report to (e.g., #my-channel).
  • job_states_to_report (optional) Which job states trigger a report. Defaults to ["success", "failure", "error"] if not set. Must be valid Prow job states.
  • report_template (optional) A Go template for the Slack message. Applied to the ProwJob instance. If not set, Prow uses its built-in default template. No alerts will be sent if the template cannot be parsed or applied.
  • report_presubmit (optional) Only relevant for periodic tests with presubmit: true. When set to true, the Slack config also applies to the presubmit job generated from the periodic. By default, periodic-only Slack config does not carry over to the presubmit.

Requirements

  • The channel must be on coreos.slack.com.
  • The channel must be public, or the @prow bot must be added to it.

Example with defaults

When only channel is provided, defaults are applied for job_states_to_report and report_template:

1
2
3
4
5
6
7
tests:
- as: "e2e"
  commands: "make test-e2e"
  container:
    from: "bin"
  reporter_config:
    channel: "#my-team"

This will report on success, failure, and error states using Prow’s default template.

Deprecated: .config.prowgen Slack configuration

The legacy .config.prowgen approach used a separate file (ci-operator/config/$org/$repo/.config.prowgen) with pattern-based job matching:

1
2
3
4
5
6
7
8
reporter_config:
- channel: "#slack-channel"
  job_states_to_report:
  - failure
  - error
  job_names:
  - unit
  - e2e

This is now replaced by the per-test reporter_config field in the ci-operator configuration, which is simpler and keeps all configuration in one place.