Hi Team,
I have a requirement where there is a condition, if the the condition is satisfied the deployment will be succeeded or else the deployment will be failed.
I am using a powershell script to fail a release by using “THROW” command.
But instead of failing the release i need to CANCEL the release
I know that there is an option to change the release state using below script:
$apikey=“xyz”
$header = @{ “X-Octopus-ApiKey” = $apikey }
$body = @{ State = ‘Failed’; Reason = ‘Cos I said so’; } | ConvertTo-Json
Invoke-WebRequest “http://octopus.xyz.com/api/tasks/ServerTasks-23030/state” -Method POST -Headers $header -Body $body
but this works only for already created releases, but my requirement is to “CANCEL” an ongoing release through API or scripts instead of failing it.
As there is an option to cancel the ongoing release manually then there might be a backend script which is doing it.
Can you please help me with that particular script or API for cancelling the release if my condition is not satisfied.
NOTE: AM USING BELOW CONDITION
$A=gc env.txt | select -index 0
if ($A -eq “Yes”)
{
echo “proceeding to next task”
}
else
{
throw “failed, as env is on freeze”
}
By this script my deployment will failed if condition is not satisfied, but i need the release to be cancelled.
It would be of great help if a solution to this problem is provided.
Thanks,
Shaik Sadiq