VSTS部署多个管道

问题描述 投票:2回答:2

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

是否可以创建一个触发其他管道的管道来组合我的发布定义,这样我就可以通过单击触发所有管道?

azure-devops
2个回答
1
投票

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

通常如下所示

enter image description here

更新1

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

enter image description here


2
投票

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

用于创建发布的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
© www.soinside.com 2019 - 2024. All rights reserved.