smcodemeister
smcodemeister

Reputation: 17

Add if-then-else logic to Azure DevOps release pipeline

I have a release pipeline in Azure DevOps. I have added an Agentless job running that calls a REST API endpoint. At the moment this works as expected. However my next challenge is to take the response from the API call and perform some tasks. Here is a breakdown of the logic I am trying to achieve:

Like I said, I have step 1 sorted but I do not know how to add the if-then-else logic

Any help appreciated Thanks

Upvotes: 0

Views: 125

Answers (1)

Nadine Raiss
Nadine Raiss

Reputation: 641

You need to look at the output of your response to get your specific value.

$reponse = Invoke-RestMethod -Method GET -URI $url
$specificValue = $response.output.specificValue
if(!$specificValue) { 
  ##value does not exist
  Invoke-RestMethod -Method POST -URI $url -Body $body
}

Upvotes: 1

Related Questions