api call returning pending when running powershell invoke-restmethod

Dustin Wilt's Avatar

Dustin Wilt

14 Feb, 2018 03:39 AM

I am attempting to get the servers that fail health check in a deployment. as there isn't any way to have the built in Health Check step output data to an output variable I am making an api call later in the script to get the task log info from the health check. however, when I make the api call it returns "Pending" for the task but if I go to the task via the api call in a browser at the same time it shows all the details. This same issue happens intermittently when running the same invoke-restmethod via non-octopus powershell session.

I'm assuming it is something with how powershell's Invoke-RestMethod is making its call but I do know that our instance of Octopus has serious delays when monitoring deploys that the interface returns "No information has been written to the task log." for long periods occasionally (sometimes 5+ minutes after the deploy has completed)

If there are better options within Octopus to make the call to the API to get the servertask details that would work but most of what I have written is in powershell. Otherwise some idea on what I might be doing wrong would be appreciated.

Here is the cmdlet I'm running and what is being returned where the browser api call is fully populated:

Invoke-RestMethod -Uri "http://#OctopusINstance#/api/tasks/ServerTasks-14593/details" -Headers $header -Method Get


February 13th 2018 21:19:41Info
Id : ServerTasks-14596_9LCLMXNF2Z
Name :
Started : 0001-01-01T00:00:00.000+00:00
Ended :
Status : Pending
Children : {}
LogElements : {}

and as we see the start time is obviously wrong.

  1. 1 Posted by Dustin Wilt on 14 Feb, 2018 03:49 AM

    Dustin Wilt's Avatar

    sorry. couple of technical pieces of info. Octopus 3.13.9 with latest Tentacle/Calamari agents installed on deployment servers.

  2. Support Staff 2 Posted by Robert Wagner on 15 Feb, 2018 03:41 AM

    Robert Wagner's Avatar

    Hi Dustin,

    Thanks for getting in touch. I'm guessing you have a HA (ie 2 or more Octopus Server node) setup. If so, the problem you are seeing with the task logs not being there (both in the UI and when you call it from your step) is due to your Octopus HA nodes not sharing the same log file directory. See this documentation on how to set this up.

    The variable you are looking for is Octopus.Deployment.AutomaticallyExcludedMachines it is "Machines that were skipped during the deployment because they went offline and the machine policy said this was ok".

    Hope that helps,

    Robert W

  3. 3 Posted by Dustin Wilt on 15 Feb, 2018 10:50 PM

    Dustin Wilt's Avatar

    You are correct in our setup. 2 Octopus Servers. I will take a look at setting up a single log file to make checking task logs more efficient.

    And you added that as a system variable. Nice. Thanks.

  4. 4 Posted by Dustin Wilt on 16 Feb, 2018 04:21 PM

    Dustin Wilt's Avatar

    yep. that was it I believe. with changing the location of the task logs to the share we store the nugget/builtin repository the invoke calls pull the data right away.


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac