66c787891e
[release/6.0.1xx] Update dependencies from dotnet/arcade - Merge branch 'release/6.0.1xx' of https://github.com/dotnet/installer into darc-release/6.0.1xx-25252fb3-bc5a-4401-85d9-c93e83346b2b - Merge branch 'release/6.0.1xx' into darc-release/6.0.1xx-25252fb3-bc5a-4401-85d9-c93e83346b2b
45 lines
1.3 KiB
PowerShell
45 lines
1.3 KiB
PowerShell
|
|
Param(
|
|
[Parameter(Mandatory=$true)][int] $buildId,
|
|
[Parameter(Mandatory=$true)][string] $azdoOrgUri,
|
|
[Parameter(Mandatory=$true)][string] $azdoProject,
|
|
[Parameter(Mandatory=$true)][string] $token
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-StrictMode -Version 2.0
|
|
|
|
function Get-AzDOHeaders(
|
|
[string] $token)
|
|
{
|
|
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":${token}"))
|
|
$headers = @{"Authorization"="Basic $base64AuthInfo"}
|
|
return $headers
|
|
}
|
|
|
|
function Update-BuildRetention(
|
|
[string] $azdoOrgUri,
|
|
[string] $azdoProject,
|
|
[int] $buildId,
|
|
[string] $token)
|
|
{
|
|
$headers = Get-AzDOHeaders -token $token
|
|
$requestBody = "{
|
|
`"keepForever`": `"true`"
|
|
}"
|
|
|
|
$requestUri = "${azdoOrgUri}/${azdoProject}/_apis/build/builds/${buildId}?api-version=6.0"
|
|
write-Host "Attempting to retain build using the following URI: ${requestUri} ..."
|
|
|
|
try {
|
|
Invoke-RestMethod -Uri $requestUri -Method Patch -Body $requestBody -Header $headers -contentType "application/json"
|
|
Write-Host "Updated retention settings for build ${buildId}."
|
|
}
|
|
catch {
|
|
Write-Error "Failed to update retention settings for build: $_.Exception.Response.StatusDescription"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
Update-BuildRetention -azdoOrgUri $azdoOrgUri -azdoProject $azdoProject -buildId $buildId -token $token
|
|
exit 0
|