通过传递不同的VariableGroup来安排多个时间安排Azure devops版本 [英] Schedule a Azure devops release in multiple timing by passing different VariableGroup
问题描述
我可以使用以下脚本在多个时间安排发布
I am able to schedule a release in multiple timing by using below script
$timinglist=@(1:30,2:30,3:30)
$PATtoken= 'PAT'
Write-Host "Initialize Autnetication COntext" -ForegroundColor DarkBlue
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PATtoken)"))
$header=@{authorization= "Basic $token" }
$defurl = "https://vsrm.dev.azure.com/Organization/Project/_apis/release/definitions/13?api-version=5.1"
$definition = Invoke-RestMethod -Uri $defurl -Method Get -Headers $header
$hash = @(
@{
triggerType="schedule";
schedule = @{"daysToRelease"="31";"timeZoneId"="India Standard Time";"startHours"=01;"startMinutes"=30}
}),
@{
triggerType="schedule";
schedule = @{"daysToRelease"="31";"timeZoneId"="India Standard Time";"startHours"=02;"startMinutes"=30}
}),
@{
triggerType="schedule";
schedule = @{"daysToRelease"="31";"timeZoneId"="India Standard Time";"startHours"=03;"startMinutes"=30}
})
$definition.triggers = $hash
$definition.variableGroups=@(10,11,12)
$json = @($definition) | ConvertTo-Json -Depth 99
$updatedef = Invoke-RestMethod -Uri $defurl -Method Put -Body $json -ContentType "application/json" -Headers $header
Write-Host ($updatedef.triggers | ConvertTo-Json -Depth 99)
我能够将变量组作为$ definition.variableGroups = @(10,11,12)传递.因此,这里的变量组10,11和12将通过三个版本中的每个版本.但是我想通过 唯一的可变组10禁止在01:30释放,可变组12在02:30释放,而11在03:30释放.有可能
I am able to pass the variable group as $definition.variableGroups=@(10,11,12) . SO here the Variable group 10,11 and 12 will get pass through each of the three releases.But i want to pass the only variable group 10 against release at 01:30 and Variable group 12 at 02:30 and 11 at 03:30. Is it possible
推荐答案
您应该使用任务组,环境和变量组来完成此任务.
You should use task groups, environments, and variable groups to accomplish this.
您定义一个任务组,其中包含您要重用的操作.
You define a task group that has the actions that you want to reuse.
您可以在单个版本中的许多不同的阶段中使用该任务组.每个发布阶段都可以绑定到不同的任务组.然后,您只需调用REST API即可触发正确阶段的部署.
You use that task groups in many different stages within a single release. Each release stage can be tied to a different task group. Then you just call the REST API to trigger a deployment of the correct stage.
这篇关于通过传递不同的VariableGroup来安排多个时间安排Azure devops版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!