Reputation: 363
I have a release A that is published in an X environment. On the other hand, I have a release B that is published in environment Y.
The problem is I would like to know if I can check the status of release A in release B and so I can throw an error and not publish release B.
I don't know if it's possible to do this with powershell or similar.
Any idea or orientation?
Upvotes: 3
Views: 742
Reputation: 18363
PowerShell script using the Azure DevOps REST API is your best bet for this. Your question is somewhat similar to this one.
You'll need to find the definition ids for the release A and environment Y. The best place to find these values is in the log output of the "Initialize Job" task from a deployment of Release A in Environment Y. Look for variables RELEASE_DEFINITIONID and RELEASE_ENVIRONMENTID.
Assuming the "classic" mode for Azure Pipelines (not YAML based):
param()
$auth = "Bearer {0}" -f $env:SYSTEM_ACCESSTOKEN
$url = "https://{0}{1}" -f $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI $env:SYSTEM_TEAMPROJECTID
$url += "/release/deployments?definitionId=" + $your_release_definition_id
$url += "&definitionEnvironmentId=" + $your_environment_definition_id
$url += "&deploymentStatus=succeeded"
$url += "&queryOrder=descending"
$url += "&api-version=5.0"
$releaseA = Invoke-WebRequest $url -Headers @{Authorization=($authHeader)} | ConvertFrom-Json
Alternatively, if this release is dependent on another release and they need to deploy together as a unit -- why not consider adding multiple artifacts to the release and deploy as a single release instead?
Upvotes: 2