在 Azure Release Pipelines 中是否可以一次手动触发多个发布管道?

In Azure Release Pipelines is it possible to manually trigger multiple release pipelines at once?

在我们的组织中,我们为每个 repo 设置了一个完整的管道(build in yaml 并使用 ui 发布,我们必须这样做才能使用部署组)。我们必须通过管道将存储库分开,因为我们经常只为该服务发布一个版本,但有时我们会同时发布多个服务(这是在发布之前已知的方式)。

目前我们只有 运行 的发布管道列表,我们 运行 每一个都是手动的。

我想知道是否有一种方法可以设置一些东西,以便在初始设置后单击 运行 关闭多个发布管道?

以下是我理想中喜欢采取的步骤:

  1. 确定需要发布哪些管道(这通常发生在计划会议的冲刺之前)
  2. 创建“东西”(另一个仅用于此版本的发布管道,另一个我不知道的 azure 选项)基本上将所有需要包含的发布管道都放在一个地方。
  3. 触发所有发布管道,以便它们 运行(好像我 运行 每个手动)

您可以使用 Trigger Azure DevOps Pipeline 然后创建另一个管道:

您可以为每个版本创建一个变量来指示您要部署的工件版本。

这样一来,您只需要在 运行 定义此版本之前编辑变量即可。

作为另一种解决方法,您可以添加 PowerShell 任务以通过 REST API 为不同的发布定义创建多个发布。

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

用于创建发行版的示例 powershell 脚本如下:

#Define the variable and enter the release definition id that you want to trigger. For example, I want to manually trigger release pipelines 1 and 2 at once.

$ReleaseDefinitionID = 1,2

ForEach ($ID in $ReleaseDefinitionID)
{
Write-host "ID is" $ID

$token = "pat"   
$url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases?api-version=5.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))


$JSON = @"
{
  "definitionId": $ID
}
"@

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON

}