Bamboo remote build agent cannot find powershell.exe after installing nodejs
Asked Answered
M

2

12

I just installed nodejs on one of my build servers (Win Server 2008 R2) which hosts a Bamboo remote agent. After completing the installation and doing a reboot I got stuck in the following situation:

The remote Bamboo build agent is running as a windows service with user MyDomain\MyUser. When a build with an inline powershell task is executing it fails with the error (from the build agent log):

com.atlassian.utils.process.ProcessNotStartedException: powershell could not be started
...
java.io.IOException: Cannot run program "powershell"
...
java.io.IOException: CreateProcess error=2, The system cannot find the file specified

Loggin on to the server as MyDomain\MyUser, I have checked that powershell is in the path:

where powershell
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

I have tried to restart the service and reboot the machine multiple times. No luck. The only thing that works is if I execute my scripts as a bat file with an absolute path to powershell - but I do not want that.

I have searched for solutions on this, but even though this one seems related: Hudson cannot find powershell after update to powershell 3 - the proposed solutions do not work.

What am I missing here?

Mislike answered 12/5, 2015 at 6:16 Comment(0)
O
17

If you do a default installation of nodejs you will see that it adds nodejs and npm to the path. Sometimes I have seen that the installer adds a user variable named PATH - it might be that the Bamboo agent decides to read the user path without "merging" it with the system path. I think it would be worth a try to give that a look.

Ought answered 12/5, 2015 at 7:15 Comment(4)
Brilliant suggestion - that was the trick. I moved the content of the user variable to the system variable, deleted the user variable PATH, and things are working again. I can't believe the Build agent is not merging both PATH variables. Anyway, this is really nice to know. Thanks again.Mislike
Saved my monday morning where all was broken. What a timebomb - quite some days since node was updated - but only when the server restarted due to Windows upgrade, the agent restarted and the error started taking place.Selsyn
I would upvote this multiple times if I could. I've had this happen on several Bamboo installs and I just keep coming back to this answer! Clearing the USER path variable does the trick.Boatyard
The existence of a user PATH variable may also cause Bamboo to always fail with the message "Failing task since return code of XXX was -1 while expected 0", this applies for the PowerShell Inline and File tasks - the same issue as described in community.atlassian.com/t5/Bamboo-questions/…. If it happens, just remote the user PATH variable :)Ought
C
1

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.

Colly answered 18/7, 2019 at 23:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.