Remote agent running as a Windows Service does not pick up the PATH variable correctly
The behavior described in this document applies to Bamboo versions below 6.10.
If you have upgraded your Bamboo instance to a version above or including 6.10 then verify that you have also upgraded the agent wrapper on all remote agents. This process is described under "Upgrading to Bamboo 6.10" section in the Version-specific upgrade notes.
Problem
Having a user variable PATH
set for the local user account, having a system variable PATH
variable set and running the Bamboo (or remote agent) Service as a local user account will cause %PATH%
to contain only the user variable PATH
. It does not append the user PATH
to the system PATH
.
Example:
User variable PATH: c:\foo
System variable PATH: c:\program files\perforce;c:\python27;c:\whatever
$> echo %PATH%
c:\foo
Commands run on the remote or local agent that exist on the system PATH
will fail with:
'<command>' is not recognized as an internal or external command
Cause
This problem is related to a bug in Java Service Wrapper (http://sourceforge.net/p/wrapper/bugs/168/) which is used by Bamboo - BAM-16205Getting issue details... STATUS
Resolution
- Upgrade Bamboo to any version above 6.10.2.
- After upgrading, perform a manual agent wrapper update as explained in this version-specific upgrade notes under Upgrading to Bamboo 6.10... section.
If the upgrade is not possible, please follow one of the following available workarounds
Workaround 1
- Manually move entries in the user variable
PATH
by either:- Moving all the entries out of the user variable
PATH
into the system variablePATH
or - Moving all entries out of the user variable
PATH
into a new user variableLOCAL_PATH
. Append%LOCAL_PATH%
to the system variablePATH
.- Example:
PATH=C:\Program Files\perforce;%LOCAL_PATH%
- Example:
- Moving all the entries out of the user variable
- Delete the user variable
PATH
so it no longer overwrites the system variablePATH
.
Alternatively, you could do the reverse and the move contents of the system variable PATH
into the user variable PATH.
Make sure the user is the same user which is running the Bamboo remote agent.
Workaround 2
Only applicable for remote agents
- Shutdown Bamboo Remote Agent
- Download the latest Java Service Wrapper: https://download.tanukisoftware.com/wrapper/3.5.35/wrapper-windows-x86-32-3.5.35.zip
Java Service Wrapper Community Edition only has 32 bits for Windows. - Extract it to an empty directory
- Replace the following files:
<remote-agent-home>\bin\wrapper.exe
<remote-agent-home>\lib\wrapper.dll
<remote-agent-home>\lib\wrapper.jar
\path\to\wrapper-windows-x86-32-3.5.35\bin\wrapper.exe
\path\to\wrapper-windows-x86-32-3.5.35\lib\wrapper.dll
\path\to\wrapper-windows-x86-32-3.5.35\lib\wrapper.jar
- If the machine only has 64-bit JDK
- Install 32-bit JDK to an empty directory
Edit the file
<remote-agent-home>\conf\wrapper.conf
to configure the full path to 32-bit JDK:wrapper.java.command=\full\path\to\32bit\jdk\bin\java
- Start the Remote Agent Windows Service
Workaround 3
Run Bamboo or the agent as a console application instead of a service via:
<bamboo-home>/bin/start-bamboo.bat
<bamboo-agent-home>/bin/BambooAgent.bat
Workaround 4
If Powershell version is version 5.1 it is suggested to not setting HTTP_PROXY/HTTPS_PROXY environment variables.
Instead of this it is recommended to use System proxy settings.
Please refer https://docs.microsoft.com/en-us/powershell/azure/az-powershell-proxy?view=azps-7.2.0