We’ve noticed that when a a running PowerShell Script step pauses partway through, the last line that was written to the console by the script is often not displayed in the Octopus Task Log until either more output is written or the step finishes.
For example, we have a script that writes a link out using Write-Host and then goes into a loop waiting for an external process to complete (using Start-Sleep to wait on each iteration). The link doesn’t get displayed in the Task Log until the loop finishes and more output is written to the console.
If we add a second Write-Host statement immediately after the link is printed and before the loop begins, then the link will be displayed but the second Write-Host statement will now be missing.
All remaining output (including the last line) also appears in the Task Log once the step completes.
Is Octopus doing some kind of buffering of the script output in the background, and not flushing the log stream to the Task Log until more output is written to the stream? Or is there some other explanation for why it might not display the last line? Is there any way we can force it to flush the output without just adding extra Write-Host statements?
We’re using PowerShell Core (v7) on Octopus Server v2022.4.8407.