Bamboo Remote agent running as a Windows Service does not pick up the PATH variable correctly
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
The behaviour 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 in the page "Bamboo remote agent installation guide" section in the Are you upgrading your version of Bamboo?
Summary
Bamboo Remote agent running as a Windows Service does not pick up the PATH
variable correctly.
Environment
Bamboo 6.10 or earlier
Diagnosis
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 exists 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-16205 - Getting issue details... STATUS
Solution
- Upgrade Bamboo to any version above 6.10.2.
After upgrading, perform a manual agent wrapper update as explained in this page - Bamboo remote agent installation guide under Are you upgrading your version of Bamboo?... 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:
<bamboo-agent-home>\bin\wrapper.exe
<bamboo-agent-home>\lib\wrapper.dll
<bamboo-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
<bamboo-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-agent-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 set 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