Created
December 22, 2022 09:31
-
-
Save rajeev-world/aa707af0f201716540963ca0d3c17098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# Declare stage variables with triggering artifacts | |
$myhash = @{"ALPHA"="_myA"; "BETA"="_myB"; "GAMMA" = "_myC"; "DELTA" = "_myD"} | |
################## Declaration done | |
$trigalias = "$(RELEASE.TRIGGERINGARTIFACT.ALIAS)" | |
if ($trigalias -ne "") { | |
$mystage = $myhash.Keys | ? { $myhash[$_] -eq $trigalias } | |
$relid = "$(RELEASE.RELEASEID)" | |
$headers = @{authorization="Bearer $env:SYSTEM_ACCESSTOKEN"} | |
$contentType = "application/json" | |
$uri = "https://vsrm.dev.azure.com/rajeevgupta0325/GlobantDevops/_apis/release/releases/"+$relid+"?api-version=5.1" | |
$data = Invoke-RestMethod -Uri $uri -Method GET -Headers $headers -ContentType "application/json" | |
foreach ($myenv in $data.environments) | |
{ | |
if ($myenv.name -eq "$mystage") {$mystageid = $myenv.id} | |
} | |
$mystageid | |
$myuri = "https://vsrm.dev.azure.com/rajeevgupta0325/GlobantDevops/_apis/Release/releases/"+$relid+"/environments/"+$mystageid+"?api-version=5.1-preview.6" | |
$myuri | |
$mybody = "{`"status`":`"inProgress`",`"scheduledDeploymentTime`":null,`"comment`":`"`"}" | |
$mydeploy = Invoke-RestMethod -Uri $myuri -Method PATCH -Headers $headers -body $mybody -ContentType "application/json" | |
$mydeploy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment