在Azure DevOps门户中,我选择一个管道,然后选择[...]菜单,然后选择删除.
我看到一条消息:
你确定吗?此操作无法撤消.这将永久删除管道'vt3e(1)'.删除包括所有构建和相关工件.
我输入管道名称并单击"确定",但管道不会删除.
我等了几个小时.
[更新]
Chrome中的F12在控制台中显示错误:
ms.vss-build-web.common-library .__ y__CePsj5f5zdcIK.min.js:18错误:版本保留与请求的管道关联的一个或多个构建.管道(s)和构建版本不会被删除
[更新]
我试图按照David D给出的答案,但是当我去删除一个版本时,我收到了一条消息
VS402946:无法删除"Release-8",因为它当前部署在阶段1的阶段.
[更新]
Ell*_*ott 56
如果您删除了相关版本,但仍然收到此错误,解决方法是:
如果该白色框/按钮不可见,则不会保留该特定运行。您可以通过单击右上角的三个点并选择“查看保留版本”来确认
Ari*_*Ari 15
用于删除构建管道(包括所有构建和租赁)的 2022 年 2 月脚本版本:
#Azure DevOps Personal Access Token
# https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows
$personalAccessToken = "<Enter your personal access token here>"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$header = @{authorization = "Basic $token"}
$organization = "<Enter your Azure DevOps Organization here>"
$project = "<Enter your Project Name here>"
$pipelineName = "<Enter the Build Pipeline Definition Name to be deleted here>"
#Get all build definitions
# API: GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.0
$url = "https://dev.azure.com/$organization/$project/_apis/build/definitions?api-version=6.0"
$allBuildDefinitions = Invoke-RestMethod -Uri $url -Method Get -ContentType "application/json" -Headers $header
$allBuildDefinitions.value | Where-Object {$_.name -eq $pipelineName} | ForEach-Object {
Write-Host $_.id $_.name $_.queueStatus
# For debugging reasons, just to be sure that we don't delete the wrong build pipeline
if ( $_.name -ne $pipelineName ) {
return;
}
#Get all Builds for a Definition
# API: GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&queues={queues}&buildNumber={buildNumber}&minTime={minTime}&maxTime={maxTime}&requestedFor={requestedFor}&reasonFilter={reasonFilter}&statusFilter={statusFilter}&resultFilter={resultFilter}&tagFilters={tagFilters}&properties={properties}&$top={$top}&continuationToken={continuationToken}&maxBuildsPerDefinition={maxBuildsPerDefinition}&deletedFilter={deletedFilter}&queryOrder={queryOrder}&branchName={branchName}&buildIds={buildIds}&repositoryId={repositoryId}&repositoryType={repositoryType}&api-version=6.0
$url = "https://dev.azure.com/$organization/$project/_apis/build/builds?definitions=" + $_.id + "&api-version=6.0"
$allBuildsOfDefinition = Invoke-RestMethod -Uri $url -Method Get -ContentType "application/json" -Headers $header
#Process each Build of Definition
$allBuildsOfDefinition.value | Where-Object {$_.retainedByRelease -eq "True"} | Sort-Object id | ForEach-Object {
#Report on retain status
Write-Host "Build Id:" $_.id " retainedByRelease:" $_.retainedByRelease
#Get all Retention Leases for this Build
# API: GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/leases?api-version=7.1-preview.1
$url = "https://dev.azure.com/$organization/$project/_apis/build/builds/" + $_.id + "/leases?api-version=7.1-preview.1"
$allLeasesOfBuild = Invoke-RestMethod -Uri $url -Method Get -ContentType "application/json" -Headers $header
#Delete each Lease of Build
$allLeasesOfBuild.value | ForEach-Object {
#Delete Lease
# API: DELETE https://dev.azure.com/{organization}/{project}/_apis/build/retention/leases?ids={ids}&api-version=7.1-preview.2
$url = "https://dev.azure.com/$organization/$project/_apis/build/retention/leases?ids=" + $_.leaseId + "&api-version=7.1-preview.2"
Invoke-RestMethod -Uri $url -Method Delete -ContentType "application/json" -Headers $header
#Report on Lease deleted
Write-Host "Lease Id:" $_.leaseId " deleted"
}
#Delete Build
# API: DELETE https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=7.1-preview.7
$url = "https://dev.azure.com/$organization/$project/_apis/build/builds/" + $_.id + "?api-version=7.1-preview.7"
Invoke-RestMethod -Uri $url -Method Delete -ContentType "application/json" -Headers $header
#Report on Build deleted
Write-Host "Build Id:" $_.id " deleted"
}
#Delete the Build Definition
# API: DELETE https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.0
$url = "https://dev.azure.com/$organization/$project/_apis/build/definitions/" + $_.id + "?api-version=6.0"
Invoke-RestMethod -Uri $url -Method Delete -ContentType "application/json" -Headers $header
Write-Host "Build Definition:" $pipelineName " (" $_.id ") deleted"
}
Write-Host "Habe fertig!"
Run Code Online (Sandbox Code Playgroud)
Dav*_*d D 12
我遇到了同样的问题并尝试了不同的浏览器,平台等.我发现通过在发布选项卡下手动删除每个版本,返回构建然后尝试删除管道再次为我工作.
在此处输入图像描述 在此处输入图像描述我遇到了以下相同的问题
与所请求的管道关联的一个或多个构建由版本保留。管道和构建不会被删除。
解决这个问题很简单,只需打开要删除的管道,如果您在管道中看到了这一点,只需单击三个点 [查看保留租约],然后打开查看保留租约,然后单击删除所有选项并关闭弹出窗口。[运行保留]。执行此操作后,您现在可以自由地删除所需的管道。
上周我遇到了同样的问题,我更新了某人的脚本以使用 5.1 API。此脚本将在发布管道保留的所有构建上运行。您将需要对您不希望所有构建都从发布中删除的进行一些调整。
$tfsServerURL = "https://dev.azure.com/{organisation}"
$TFSProject = "{project}"
$AzureDevOpsPAT = "{token}"
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)"))}
#Set to $true to update builds by settingretainingByRelease= false
$CorrectError = $true
$URL = "$($tfsServerURL)/$($TFSProject)"
Write-Output $URL
#Get all builddefinitions in Project
$Buildefinitions = (Invoke-RestMethod -Uri ($URL + '/_apis/build/definitions?api-version=5.1') -Method GET -UseDefaultCredentials -Headers $AzureDevOpsAuthenicationHeader).value
foreach($Builddefiniton in $Buildefinitions)
{
Write-Output "Searching in $($Builddefiniton.name) with id $($Builddefiniton.id)"
#Get Builds with keepforever = false and retainedByRelease = true
$Builds = (Invoke-RestMethod -Uri ($URL + '/_apis/build/builds?definitions=' + $Builddefiniton.id + '&api-version=5.1') -Method GET -UseDefaultCredentials -Headers $AzureDevOpsAuthenicationHeader).value | where {$_.keepForever -eq $False -and $_.retainedByRelease -eq $true}
#Get releases linked to the build
foreach ($build in $Builds)
{
If ($CorrectError)
{
Invoke-RestMethod -Uri ($URL + '/_apis/build/builds/'+ $build.id + '?api-version=5.1') -Method Patch -Body (ConvertTo-Json @{"retainedByRelease"='false'}) -UseDefaultCredentials -Headers $AzureDevOpsAuthenicationHeader -ContentType "application/json" | Out-Null
Write-Output "`tFixed"
}
}
}
Run Code Online (Sandbox Code Playgroud)
PowerShell 脚本将首先获取所有构建管道,然后获取所有未无限保留并由发布保留的构建。如果将 CorrectError 设置为 true,则脚本将尝试将 reservedByRelease 标志切换为 false。
运行此脚本后,我能够删除构建管道。
如果我尝试删除管道,我会得到同样的错误:
与所请求的管道关联的一个或多个构建由版本保留。管道和构建不会被删除。
在管道页面上,转到“运行”选项卡,应该会看到记录列表。如果单击该行右侧的三个点,您应该会看到一个查看保留租约的选项。如果您删除全部,您应该能够删除该行。然后,您需要对运行选项卡中的每一行重复此步骤,直到删除所有运行。
只有这样您才能删除父管道。
| 归档时间: |
|
| 查看次数: |
4849 次 |
| 最近记录: |