Powershell script hangs
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
Powershell scripts doesn't return control to Bamboo, build hangs forever.
Cause
Bamboo expect child process to close its output stream (stdout and stderr) when exiting. Powershell doesn't do it.
Resolution
If you're creating an executable for Powershell and running it via a Command task, add a '
-inputformat none'
to the command argument. The command argument field should look like this:-inputformat none -command
If directly calling Powershell script from Bamboo, use Script task with 'Run as Powersell script option on'. Bamboo script task can handle this situation.
If Powershell is called indirectly (e.g. from ant, nant, maven, other script), make sure that the streams are closed on exit:
powershell .\test.ps1 < NUL
Was this helpful?