You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TFS 2018能否配置集合级全局通知?如何实现跨项目构建失败通知?

TFS 2018: Global Build Failure Notifications for Entire Collection

Great question! Let's break this down clearly for your TFS 2018 setup:

Does TFS 2018 support collection-wide global notifications?

TFS 2018 doesn’t have a built-in GUI option to set global collection-wide notifications directly. However, you have two reliable workarounds to avoid the tedious manual setup for each of your 30+ projects.

Workaround 1: Batch Create Subscriptions via TFS REST API

You can use TFS’s REST API to automate creating build failure alerts for every project in your collection. Here’s a step-by-step approach with a PowerShell script example:

  1. First, we’ll fetch all projects in your collection, then loop through each to create the alert.
  2. Use this PowerShell script (replace the placeholder values with your TFS details):
$tfsUrl = "http://your-tfs-server:8080/tfs/YourCollectionName"
$apiVersion = "4.1"
$teamNotificationEmail = "your-team-email@company.com"

# Retrieve all projects in the target collection
$allProjects = Invoke-RestMethod -Uri "$tfsUrl/_apis/projects?api-version=$apiVersion" -Method Get -UseDefaultCredentials

# Loop through each project to create the build failure alert
foreach ($project in $allProjects.value) {
    $projectId = $project.id
    $alertPayload = @{
        name = "Build Failure Alert - $($project.name)"
        description = "Triggers email when any build fails in the $($project.name) project"
        filter = @{
            eventType = "build.complete"
            criteria = "Build.Status = Failed"
        }
        subscriber = @{
            descriptor = "Microsoft.TeamFoundation.Identity;$teamNotificationEmail"
        }
        channel = @{
            type = "email"
            address = $teamNotificationEmail
        }
        scope = @{
            type = "project"
            id = $projectId
        }
    } | ConvertTo-Json -Depth 10

    # Send the API request to create the alert
    Invoke-RestMethod -Uri "$tfsUrl/_apis/notification/subscriptions?api-version=$apiVersion" -Method Post -Body $alertPayload -ContentType "application/json" -UseDefaultCredentials
    Write-Host "Successfully created alert for project: $($project.name)"
}
  • Run this script on a machine with access to your TFS server (it uses Windows auth by default).
  • This will automatically set up the build failure email alert for every existing project in your collection.

Workaround 2: Use Alert Templates with TFS Power Tools

If you prefer a more GUI-first approach combined with batch operations, use TFS Alert Templates and the official TFS Power Tools:

  1. Create a Custom Alert Template:

    • Open your TFS web portal, click the gear icon (Settings) → Alert Templates.
    • Create a new template, name it something like "Global Build Failure Alert".
    • Configure the trigger: Select Build completes as the event, set the criteria to Build status is Failed, and add your team email as the recipient.
  2. Batch Apply the Template to All Projects:

    • Install the TFS 2018 Power Tools (official Microsoft tooling).
    • Open Command Prompt and run this command (replace placeholders):
    tfpt alert /collection:http://your-tfs-server:8080/tfs/YourCollectionName /template:"Global Build Failure Alert" /applytoall
    

    This command will apply your custom alert template to every project in the collection in one go.

Bonus Tip for New Projects

To avoid manual setup for future projects:

  • Schedule the PowerShell script to run periodically (via Windows Task Scheduler) to check for new projects and add the alert automatically.
  • Or, whenever you create a new project, re-run the tfpt alert command or the PowerShell script to include it.

内容的提问来源于stack exchange,提问作者shaboinkin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:26:56