VSTS部署多个管道

时间:2018-08-31 12:41:45

标签: azure-devops

现在我已经配置了多个管道,每个管道都有自己的任务和变量。要部署所有程序,我需要一个接一个地手动部署。

是否可以创建一个触发其他管道以组合我的发布定义的管道,以便单击即可触发所有管道?

2 个答案:

答案 0 :(得分:2)

要为多个版本定义创建多个版本,可以通过REST API添加PowerShell任务为不同的版本定义创建版本。

用于创建发布的PowerShell脚本,如下所示:

$body = '
{
    "definitionId": releasedefinitionID,
     "artifacts": [
        {

      "alias": "",
      "instanceReference": {
        "id": "buildID",
        "name": null
      }

        }
    ]
}
'
$bodyJson=$body | ConvertFrom-Json
Write-Output $bodyJson
$bodyString=$bodyJson | ConvertTo-Json -Depth 100
Write-Output $bodyString
$user="name"
$token="PAT"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$Uri = "https://account.vsrm.visualstudio.com/project/_apis/Release/releases?api-version=4.1-preview.6"
$buildresponse = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body $bodyString -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
write-host $buildresponse

答案 1 :(得分:1)

是的,您可以发布管道中有一个名为 Predeployment condition 的选项,其中有一个名为 trigger 的菜单,您可以在其中更改/控制触发器类型。

通常如下所示

enter image description here

更新1

为了并行部署多个环境,请将触发选项从after environment更改为after release

enter image description here

相关问题