Allow chat integrations to notify only when pipeline status changes
What does this MR do and why?
This MR adds a status change–based notification option to chat integrations
that use Integrations::Base::ChatNotification.
- It introduces a new
notify_only_when_status_changesoption for chat integrations. - When enabled, pipeline notifications are sent only when the ref status changes
(for example, when
ref_status_nametransitions tofixedorbroken), instead of on every pipeline completion. - The option is wired through the shared
ChatNotificationbase concern and applied to multiple chat providers (such as Discord, Matrix, and others), so that they all share the same status-change notification behavior. - The option is initialized to
falsefor new integrations to preserve the existing default behavior.
This reduces noisy pipeline notifications and makes chat notifications more focused on meaningful status changes, while keeping the previous behavior available when the option is disabled.
References
How to set up and validate locally
These steps use the Discord integration as an example, but the same behavior
should apply to any webhook-based chat integration that uses
Integrations::Base::ChatNotification.
1. Prepare a test project and Discord webhook
-
In your GDK, open a test project with a simple
.gitlab-ci.yml, for example:stages: - test test: stage: test script: - echo "ok" -
Push a commit to the default branch that makes the pipeline succeed.
-
In Discord, create a test server and an incoming webhook URL.
-
In the GitLab project, go to Settings > Integrations > Discord notifications.
-
Paste the Discord webhook URL.
-
Enable Pipeline events.
-
Enable the new Notify only when status changes checkbox.
-
Save the integration.
2. Verify "Notify only when status changes" behavior
- Push a commit to the default branch that makes the pipeline succeed.
Expected: Discord doesn't receive a pipeline notification when the ref status does not change. - Modify
.gitlab-ci.ymlto make the pipeline fail (for example,exit 1) and push a commit.
Expected: Discord receives a notification when the ref status changes to "broken". - Push a commit to the default branch that makes the pipeline fail.
Expected: Discord doesn't receive a pipeline notification when the ref status changes to "still_failing". - Fix the pipeline (make it succeed again) and push another commit.
Expected: Discord receives another notification when the ref status changes to "fixed".
3. Verify "Notify only when status changes" and "Notify only broken pipelines" behavior
- Modify
.gitlab-ci.ymlto make the pipeline fail (for example,exit 1) and push a commit.
Expected: Discord receives a notification when the ref status changes to "broken". - Fix the pipeline (make it succeed again) and push another commit.
Expected: Discord doesn't receive a notification because "Notify only broken pipelines" is enabled, even though the ref status changed to "fixed".
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.