I have a few deployments on my dashboard that were showing as ‘Failed’. I was able to use the following script to modify the status from ‘Failed’ to ‘Cancelled’
$apikey = 'APIHFHFHFHFHFHFHFHFH'
$header = @{"X-Octopus-ApiKey"=$apikey}
$serverTaskId = 'ServerTasks-1638'
$octopusUri = "https://$instanceName.octopus.com/api/tasks/$serverTaskId/state"
$data = @{state='Failed'; reason='Application was removed as part of installation of Contoso.Schemas.'}
$body = $data | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri $octopusUri -Body $body -Headers $header
I’d those deployments to not show at all anymore on my dashboard. Is there anyway to do that?
There actually is an API call you can utilize to clear out that deployment. You can do a DELETE on a deployment endpoint. To get the deployment ID to run the DELETE on, you would go to the release in the api, then find the desired environment in the JSON to get the ID, then run the delete on that ID.