Is it possible to check whether the servers using in an environment for a particular project (something like Website project pre-production) are online before attempting a deployment? We are having problems with servers dropping from DNS which causes them to disconnect from Octopus Deploy.
I was hoping there would be a switch in octo.exe but I didn’t find anything.
Thanks for getting in touch! There’s not a straight way to do so from Octo.exe, but you could add a step at the beggining of your deployment process to force a health check on all the machines on that environment using the REST API. When you start the health check you’ll get a response with a task link where you can check the status of the health check task.
Thanks for your quick response Dalmiro. Yes, I’d still like to know how to do this from the API. I need to verify the health of our tentacles from a Process Step. If a tentacle is gone (in a cloud deployment), I’ve found that a tentacle can be gone for 1 hr before it appears as disconnected.
Here’s an example for the REST API call using Powershell
$OctopusURL = "http://YourURL"
$OctopusAPIKey = "YourOctopusAPIKey"
$environmentID = "YourEnvironmentID" #Id of the environment where you want to run the health check. During a deployment you can use the variable $OctopusParameters['Octopus.Environment.Id'] to get this value.
$header = @{ "X-Octopus-ApiKey" = $OctopusAPIKey }
$body = @"
{
"Name":"Health",
"Description":"Check Deployment Target health in Development",
"Arguments":{
"Timeout":"00:05:00",
"EnvironmentId":"$environmentID"
}
}
"@
Invoke-WebRequest -Uri $OctopusURL/api/tasks -Body $body -Headers $header -Method Post
Thanks for your help Dalmiro. I’m proceeding down this path, but haven’t been able to test it yet.
{
ErrorMessage: "You do not have permission to perform this action. Please contact your Octopus administrator. Missing permission: TaskCreate"
HelpText: "This action requires permission to explicitly create (run) server tasks. At least one of your teams has this permission in a limited scope, but this doesn't cover the project or environment in question. Teams that have enough permission include: Octopus Administrators."
}
Our Octopus admin says I have TaskCreate access (via my team’s access to a role he created with “TaskCreate” enabled), though. I’ll let you know how it goes once I can gain access to the API. I’ll probably look for another topic related to this specific permissions problem.
The team that grants you the “TaskCreate” role should be scoped to “All projects”, and not just the ones that are currently using that Environment. That’s most likely why you are getting that error.
hi, when i execute the following script below get a "remote server returned a 500 error"
Just wondering if this invoke-webrequest still works,
Thank you,
-Greg
$OctopusURL = “http://YourURL”
$OctopusAPIKey = “YourOctopusAPIKey”
$environmentID = “YourEnvironmentID” #Id of the environment where you want to run the health check. During a deployment you can use the variable $OctopusParameters[‘Octopus.Environment.Id’] to get this value.
I worked out that I was using environment name instead of ID…can use the
environment name instead ? for example: Development instead of
environmentID-80
I’m not really liking octoposh I rather use invoke-webrequest