tfsbuild 删除/销毁 - 未发现构建规范的构建 [英] tfsbuild delete/destroy - founds no builds for build specification

查看:21
本文介绍了tfsbuild 删除/销毁 - 未发现构建规范的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论保留设置如何,我们的构建定义中都会无限期地保留 100 个构建:我想删除带有脚本的构建,我正在尝试从远程 PC 运行.我们的tfs服务器是2015.2.

There are 100s of builds left in our build definition indefinitely, regardless of the retention settings: i want to delete builds with scripts, i am trying run from remote PC. our tfs server is 2015.2.

tfsbuild destroy /collection:http://tfsserver:8080/tfs/ProjectCollection /dateRange:01/01/2017~31/12/2017 /buildDefinition:teamProject\Builddefintion

输出显示:未找到构建规范的构建.即使有许多构建符合标准.任何帮助表示赞赏.谢谢!

output shows: No builds found for build specification. even though there are many builds meets the criteria. any help is appreciated. Thanks!

推荐答案

Tfsbuild delete/destroy 仅适用于 Xaml 构建.并且需要先delete然后destroy.

Tfsbuild delete/destroy only availabe for Xaml builds. And need to delete first then destroy.

对于 vNext 构建,您可以尝试使用 REST API 删除它们(删除构建):

For vNext builds, you can try to delete them with the REST API (Delete a build):

DELETE http://server:8080/tfs/DefaultCollection/ProjectName/_apis/build/builds/{build Id}?api-version=2.0

您可以使用下面的 PowerShell 脚本删除在 2017 年完成的所有构建,以进行特定的构建定义:

You can use below PowerShell script to delete all the builds which compeleted in the year 2017 for the specific build definiiton:

Param(
   [string]$collectionurl = "http://server:8080/tfs/Collection",
   [string]$projectName = "ProjectName",
   [string]$builddefinitionID = "56",
   [string]$keepForever = "true",
   [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)))

#Get builds list which completed in the year 2017
$buildsUrl = "$($collectionurl)/$projectName/_apis/build/builds?definitions=$builddefinitionID&statusFilter=completed&api-version=2.0"   
$builds = (Invoke-RestMethod -Uri $buildsUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}).value | where({$_.finishTime -like '*2017*'})

#Delete the builds 
foreach ($build in $builds.id)
{
$deleteurl = "$($collectionurl)/$projectName/_apis/build/builds/$build"+"?api-version=2.0"

$result = (Invoke-RestMethod -Uri $deleteurl -Method Delete -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})

Write-Host "Builds deleted with the ID" : $build 
}

这篇关于tfsbuild 删除/销毁 - 未发现构建规范的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆