PHASE 12 OF 15

Notifications

Email SMTP setup, notification rules for failures and fixes, branch filters, Freemarker templates for custom emails, Slack integration via webhook, and build status badges

EmailSlackNotificationsFreemarkerStatus Badge
1

Notification Types

NotifierAvailabilityNotes
EmailBuilt-inRequires SMTP server configuration. Most commonly used.
Jabber/XMPPBuilt-inInstant messaging via XMPP protocol. Rarely used today.
IDE (IntelliJ, Eclipse)Built-in (requires plugin)Notifications in IDE status bar. Requires developer to install TC IDE plugin.
Windows system trayBuilt-in (Windows only)Popup notifications in Windows system tray.
SlackVia custom notifier / webhookNot built-in — implemented via Command Line step or build feature. See section 12.7.
2

Email Notifier Setup

  1. Go to Administration → Email Notifier.
  2. Fill in SMTP settings:
FieldExample
SMTP hostsmtp.gmail.com or internal SMTP server
SMTP port587 (TLS/STARTTLS) or 465 (SSL) or 25 (plain)
Send email fromteamcity@yourcompany.com
LoginSMTP username (often same as from address)
PasswordSMTP password or app password
Secure connectionSTARTTLS (port 587) or SSL (port 465)

Click Test connection — TeamCity sends a test email to the admin address. Verify it arrives before saving.

GOTCHA — Gmail requires App Password

If using Gmail, your Google account must have 2FA enabled, and you need to create an App Password (Google Account → Security → App passwords). The regular Gmail password won't work — Google blocks "less secure app" access. The App Password is a 16-character code used only for TeamCity.

3

Notification Rules & Events

Notification rules define WHO gets notified WHEN. They can be set at the user level (My Settings & Tools → Notification Rules) or at the group level.

Available notification events
EventFires whenRecommended for
Build failedAny build in the rule's scope failsAll developers on the team
First build failureA build fails AFTER a successful build (new failure)Reduced noise — only alerts on newly broken builds
Build successfulAny build passesUsually too noisy — avoid for active repos
Build fixedA build passes AFTER having failedThe person who fixed it, or the whole team
Build startsAny build enters the running stateVery noisy — rarely used
Probably hangingBuild exceeds its expected duration thresholdOn-call team — stuck build detection
Responsibility changedA developer is assigned as "responsible" for a failureThe assigned developer
Setting user notification rules
  1. Go to My Settings & Tools (top right) → Notification Rules.
  2. Click Add new rule.
  3. Choose the notifier type (Email, IDE, etc.).
  4. Scope: specific build configurations, all configs in a project, or all watched configs.
  5. Events: check the events to notify on.
  6. Branch filter (optional): only notify for failures on specific branches.
RECOMMENDED RULE SET

For most developers: Email on First build failure + Build fixed on the main branch only. This gives you one email when main breaks and one when it's fixed — without a flood of feature-branch failure emails. Feature branch failures should be the developer's own responsibility to check.

4

User-Level vs Group Notification Rules

LevelWho configures itScope
User levelEach user in their own profileApplies only to that user
Group levelSystem or project adminApplies to all users in the group; users can add their own rules on top

Group-level rules are useful for ensuring the whole team gets notified of main branch failures without requiring every developer to configure their own rules. Go to Administration → User Groups → <Group> → Notification Rules.

5

Branch-Specific Notification Filters

In a notification rule, add a branch filter to limit notifications to specific branches. Same +/- syntax as VCS Root branch specs:

# Notify only for main and release branches
+:refs/heads/main
+:refs/heads/release/*

# Notify for everything except feature branches
+:refs/heads/*
-:refs/heads/feature/*
6

Notification Templates (Freemarker)

TeamCity's email notification content is defined by Freemarker templates stored in the data directory at <Data Dir>/config/notification/email/. You can customise the subject and body.

# Default template location:
<TC Installation>/webapps/ROOT/WEB-INF/BSPTags/email/*.ftl

# To customise without modifying the installation:
# Copy to: <Data Dir>/config/notification/email/
# Edit there — TeamCity uses these over the defaults.

# Example: customise failure email subject
# File: <Data Dir>/config/notification/email/build_failed.ftl
Subject: [TC] FAILED: ${build.buildType.fullName} #${build.buildNumber} on ${build.branch.name!"default"}

# Available template variables include:
# ${build} — the build object (status, number, branch, params)
# ${buildType} — the build configuration
# ${project} — the project
# ${changes} — list of VCS changes
# ${firstFailedBuild} — the first build that introduced the failure
7

Slack Integration via Webhook

TeamCity 2017.2.2 has no built-in Slack notifier. Implement it with a Command Line build step that posts to a Slack incoming webhook, set to run "even if previous steps failed."

Setup
  1. In Slack: Your workspace → Apps → Incoming Webhooks → Add to Slack. Select channel. Copy the webhook URL.
  2. Store it in TeamCity as a password parameter: env.SLACK_WEBHOOK_URL.
  3. Add a Command Line step to your build config:
#!/bin/bash
# Slack notification step (execute: even if previous steps failed)

STATUS="$BUILD_STATUS"
COLOR="good"
if [ "$STATUS" = "FAILURE" ]; then COLOR="danger"; fi
if [ "$STATUS" = "SUCCESS" ]; then COLOR="good"; fi

PAYLOAD=$(cat <<EOF
{
  "attachments": [{
    "color": "$COLOR",
    "title": "$BUILD_CONFIGURATION: #$BUILD_NUMBER",
    "title_link": "${TEAMCITY_SERVER_URL}/viewLog.html?buildId=${BUILD_ID}",
    "text": "Branch: ${BUILD_BRANCH}\nStatus: $STATUS",
    "footer": "TeamCity"
  }]
}
EOF
)

curl -s -X POST -H 'Content-type: application/json' \
  --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"

Parameters used: %teamcity.build.status%, %build.number%, %teamcity.build.branch%, %build.id%, %teamcity.serverUrl% — these are standard predefined parameters from Phase 8.

8

Build Status Badge

TeamCity generates a status badge image you can embed in GitHub READMEs or wikis.

# Badge URL format:
http://YOUR_TC_SERVER/app/rest/builds/buildType:(id:BuildConfigId)/statusIcon

# For HTTPS server:
https://ci.yourcompany.com/app/rest/builds/buildType:(id:BackendServices_Build)/statusIcon

# Embed in GitHub README.md:
[![Build Status](https://ci.yourcompany.com/app/rest/builds/buildType:(id:BackendServices_Build)/statusIcon)](https://ci.yourcompany.com/viewType.html?buildTypeId=BackendServices_Build)

# Optional: filter to specific branch
https://ci.yourcompany.com/app/rest/builds/buildType:(id:BackendServices_Build),branch:(name:main)/statusIcon
GOTCHA — Guest access required for public badges

The status badge URL requires authentication unless Guest User is enabled on the TeamCity server (Phase 13). For private servers showing badges on public GitHub repos, enable Guest User with read-only access limited to the specific project. Without this, the badge will show an authentication error icon.

Up Next — Phase 13: User Management & Security

Set up roles and permissions, configure LDAP/Active Directory authentication, enable two-factor authentication, manage API tokens, and review the audit log.

Continue to Phase 13 → Back to Hub