0

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)

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

mystack
  • 4,910
  • 10
  • 44
  • 75
  • Not get your latest information, is the workaround helpful for you? Or if you have any concern, feel free to share it here. – Hugh Lin Dec 02 '19 at 09:59

1 Answers1

0

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.

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.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120