Monday, July 07, 2025

Gitlab-CE Disable Pipeline Emails Self Hosted

Liam Killingback
Tutorial
404

Disable Pipeline Notification Emails on Self-Hosted GitLab CE

If you’ve ever enforced mandatory pipeline checks on your self-hosted GitLab CE instance, you know how quickly your inbox can fill up with pipeline success, failure, and “fixed” alerts. Unfortunately, GitLab CE doesn’t expose a UI toggle to disable these notifications globally—so here’s a quick hack: patch the mailer in the Rails code, then restart GitLab.

⚠️ Warning:

  • Upgrades will overwrite your changes. Keep this guide handy to reapply the patch after each GitLab upgrade.
  • Always backup the original file before modifying it.

Prerequisites

  • SSH access to your GitLab server
  • sudo privileges (or root) on that server
  • A text editor like nano, vim or emacs

1. SSH into Your GitLab Server

ssh your-user@your-server-ip

2. Backup the Pipeline Mailer

Before editing, make a copy so you can restore it if needed:

sudo cp \
  /opt/gitlab/embedded/service/gitlab-rails/app/mailers/emails/pipelines.rb \
  /opt/gitlab/embedded/service/gitlab-rails/app/mailers/emails/pipelines.rb.bak

If the file path differs in your version, search for the mailer:

sudo grep -R "class PipelinesMailer" -n /opt/gitlab/embedded/service/gitlab-rails

3. Edit the Pipeline Mailer

Open the mailer in your editor:

sudo nano /opt/gitlab/embedded/service/gitlab-rails/app/mailers/emails/pipelines.rb

Locate the methods responsible for sending notifications. They’ll look something like:

def pipeline_email("Success"), do: ...
def pipeline_email("Failed"),  do: ...
def pipeline_email("Fixed"),   do: ...

Apply the “No-Op” Patch

Replace each method body with an immediate return, for example:

-def pipeline_email("Failed")
-  # existing delivery logic…
-end
+def pipeline_email("Failed")
+  # disabled: no email on pipeline failure
+  :ok
+end

Do the same for "Success" and "Fixed":

-def pipeline_email("Success"), do: deliver_success_email(...)
+def pipeline_email("Success")
+  # disabled: no email on pipeline success
+  :ok
+end

-def pipeline_email("Fixed"), do: deliver_fixed_email(...)
+def pipeline_email("Fixed")
+  # disabled: no email on pipeline fix
+  :ok
+end

Save and exit (Ctrl+X, Y, Enter in nano).


4. Restart GitLab

Apply your changes by restarting all GitLab services:

sudo gitlab-ctl restart

Monitor the restart:

sudo gitlab-ctl status

Once everything is up, your team should stop receiving pipeline emails.


5. Maintenance & Rollback

  • After each upgrade, reapply the patch by repeating steps 2–4 (or automate with a script).

  • To rollback, restore the backup and restart:

    sudo mv \
      /opt/gitlab/embedded/service/gitlab-rails/app/mailers/emails/pipelines.rb.bak \
      /opt/gitlab/embedded/service/gitlab-rails/app/mailers/emails/pipelines.rb
    
    sudo gitlab-ctl restart

Alternative Approaches

  1. Project-level notification settings

    • Each user can dial down their own pipeline emails under Profile → Notifications → Custom.
    • Not a global solution, but useful if only a few users need quieter inboxes.
  2. Use a custom Notification Service

    • Implement a webhook-based service that filters or suppresses unwanted events.
    • Requires more setup but survives GitLab upgrades intact.

Conclusion

Patching the Rails mailer is a quick—and admittedly hacky—way to silence pipeline notifications on GitLab CE. While you lose the ability to granularly tune which pipelines you care about, you’ll gain peace of mind (and an uncluttered inbox). Just remember: document your changes, backup your files, and reapply after upgrades. Happy coding!