无论保留设置如何,我们的构建定义中都会剩余100个构建:我想删除带脚本的构建,我尝试从远程PC运行。我们的tfs服务器是2015.2。
tfsbuild destroy /collection:http://tfsserver:8080/tfs/ProjectCollection /dateRange:01/01/2017~31/12/2017 /buildDefinition:teamProject\Builddefintion
输出显示:找不到构建规范的构建。即使有许多构建符合标准。任何帮助表示赞赏。谢谢!
答案 0 :(得分:0)
Tfsbuild delete/destroy
仅适用于Xaml版本。然后需要先delete
然后destroy
。
对于vNext版本,您可以尝试使用REST API(Delete a build)删除它们:
DELETE http://server:8080/tfs/DefaultCollection/ProjectName/_apis/build/builds/{build Id}?api-version=2.0
您可以使用以下PowerShell脚本删除2017年针对特定构建定义而竞争的所有构建:
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
}