用于获取所有 Azure 发布管道的内部版本号列表的脚本

时间:2021-04-02 19:03:22

标签: azure powershell shell azure-devops

我正在寻找脚本/命令来获取所有 Azure 发布管道的内部版本号列表。有谁知道方法吗?

1 个答案:

答案 0 :(得分:0)

您可以使用 Releases - List REST api 获取发布列表:

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=6.0

脚本如下:

Param(
   [string]$org = "orgName",
   [string]$projectName = "projectName",
   [string]$keepForever = "true",
   [string]$user = " ",
   [string]$token = "PAT"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
write-host $WorkitemType

$uri = "https://vsrm.dev.azure.com/$org/$projectName/_apis/release/releases?api-version=6.0"
$result = Invoke-RestMethod -Uri $uri -Method Get -Body $json -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
Write-Host "$($result | ConvertTo-Json -Depth 100)"