tfs - 在 TFS 2015 中,对于失败的 VNext 构建,构建失败的步骤(构建任务)是否存储在 DB 中的任何位置
问题描述
我知道如果我单击构建链接以获取摘要,它会显示所有步骤,但我无法使用 API 或查看 TFS 数据库在任何地方找到构建失败的实际步骤(构建任务)。
TFS 2015 是否将其存储在任何可访问的地方?
解决方案
Timeline
您可以使用 REST API ( Timeline - Get )从构建中检索失败的步骤
只需尝试以下 PowerShell 示例以从构建中检索失败的步骤(构建任务):
Param(
[string]$collectionurl = "http://ictfs2015:8080/tfs/DefaultCollection",
[string]$projectName = "ProjectName",
[string]$BuildId = "44",
[string]$user = "username",
[string]$token = "password"
)
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$uri = "$($collectionurl)/$($projectName)/_apis/build/builds/$BuildId/timeline?api-version=2.0"
$response = Invoke-RestMethod -Uri $uri -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$steps = $response.records | where {$_.result -eq 'failed' -and $_.type -eq 'Task'} # Filter the failed steps
$failedsteps = @()
foreach($step in $steps){
$customObject = new-object PSObject -property @{
"StepId" = $step.id
"type" = $step.type
"TaskName" = $step.name
"startTime" = $step.startTime
"finishTime" = $step.finishTime
"state" = $step.state
"result" = $step.result
"changeId" = $step.changeId
"workerName" = $step.workerName
}
$failedsteps += $customObject
}
$failedsteps | Select `
StepId,
type,
TaskName,
startTime,
finishTime,
state,
result,
changeId,
workerName #|export-csv -Path C:\FailedBuildSteps.csv -NoTypeInformation
推荐阅读
- swift - 自定义 NSButton 未按预期显示
- python - 您将如何使用 IF NOT 语句,但有 2 个选项
- git - `git stash show` 的输出为空
- css - 我们应该如何使用不同的谷歌字体?
- java - 我映射不正确的是什么?“字段列表”中的未知列
- r - 对 R 闪亮的 dateRangeInput 使用相同的最小/最大日期和开始/结束日期
- javascript - 如何将基于 require.js 的脚本作为组件包含到 Angular 中
- android - 为什么android studio用红色显示这个项目
- javascript - 清除框字段时如何删除无结果消息
- c - 快速,绘制数据集_如何计算绘图的线数