Skip to main content

Powershell will not run on new bamboo agent service running on Windows 10 [Resolved]

I'm trying to set up a new CI build node in our bamboo system. I have a bamboo agent running as a windows service in this build node, I have a similar setup running on a windows-server 2012, but now I want to create the same setup in Windows 10.

A lot of the windows build jobs use powershell as part of the build process to publish artifacts to other repos, they are set up as a Script Task in the bamboo job configurations, and like I said, it runs just fine in the WS2012 build machine.

In the new windows 10 node, I get an error saying that the script returned with RC -1 instead of 0. I tried just running echo "hello" on the script to see if it was some compatibility with the new OS, but I still got the same error, this made me think it is a permissions issue. I checked the execution policy, it's set to RemoteSigned, I checked that the service is running with an account with Administrator priviledges. I still get the same problem. The only thing that is weird is how bamboo calls the script it uses

powershell -ExecutionPolicy bypass -Command scriptName.ps1

instead of the using the -File option to run from the command line, but this works in the other node, so I am not sure, the main difference beside the host OS is the powershell version, Windows 10 uses powershell 5.1 the older node is using 5.0 so, my question to you guys is: What else can I check? Any thoughts?

Question Credit: Jose Villalta
Question Reference
Asked July 20, 2019
Posted Under: Network
2 Answers

So the problem was that the env was missing a path to powershell in the user path variable. Adding it fixes the problem. I had wrongly assumed that since powershell came with the OS that the path would automatically be available.

credit: Jose Villalta
Answered July 20, 2019

As per Atlassian support page, this is related to a bug in Java Service Wrapper. I tried Workaround-2 since there was no user PATH variable in my system. I had to uninstall bamboo agent service and Java 64 versions from the agent machine to apply the workaround-2.

credit: Jerin
Answered July 20, 2019
Your Answer