【发布时间】:2019-11-27 11:06:10
【问题描述】:
我可以使用 Rest API call 来安排发布。有没有办法让它多次运行。我试过的代码如下。
$timinglist=@(1:30,2:30,3:30)
foreach($time in $timinglist)
{
$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
$hour=$time.Split(":")[0]
$minute=$time.Split(":")[1]
$hash = @(
@{
triggerType="schedule";
schedule = @{"daysToRelease"="31";"timeZoneId"="India Standard Time";"startHours"=$hour;"startMinutes"=$minute}
})
$definition.triggers = $hash
$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)
}
我的目标是在 1:30 2:30 和 3:30 排队发布。但是使用上面的代码,它只在 3:30 运行,其他两个没有发生。
【问题讨论】:
标签: powershell azure-devops azure-pipelines azure-pipelines-release-pipeline azure-devops-rest-api