Incorrect environment variables when running remote agent on macOS

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

Summary

After installing the remote agent as a daemon on macOS builds start to fail because environment variables are not being picked.

Diagnosis

Create a test plan with a script task to print the environment variables:

echo $JAVA_HOME
echo $PATH

Cause

By default, the macOS daemon does not pick environment variables.

Solution

There are two possible solutions for this issue. We can either set the environment variables on the plist file or at wrapper.conf:

Option A

You can set the environment variables in <Bamboo agent home>/conf/wrapper.conf, copy your JAVA_HOME and PATH and insert them in the wrapper configuration. E.g.

# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=FALSE
set.JAVA_HOME=/path/here
set.PATH=/path


Restart the service.

More information on Wrapper environment variables configuration: Environment Variable Definition

Option B


You can configure them in the plist file {{/Library/LaunchDaemons/org.tanukisoftware.wrapper.bamboo-agent.plist}} like in the example below. Add the following inside the dict:

<key>EnvironmentVariables</key>
<dict>
	<key>JAVA_HOME</key>
	<string>/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home</string>
	<key>PATH</key>
	<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin</string>
</dict>


Then reload the daemon:

sudo launchctl unload -w /Library/LaunchDaemons/org.tanukisoftware.wrapper.bamboo-agent.plist
sudo launchctl load -w /Library/LaunchDaemons/org.tanukisoftware.wrapper.bamboo-agent.plist



Last modified on Mar 31, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.