How to customize Java Virtual Machine (JVM) and wrapper settings for your Bamboo elastic agents
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
Summary
This page will walk you through how to customize Java Virtual Machine (JVM) and wrapper settings for your elastic agents. This can be done using the JVM arguments listed below.
Environment
This has been tested on Bamboo 8.2.5 but likely works with other versions.
Solution
As mentioned, it is possible to use JVM arguments to customize elastic agents. Below is a non-exhaustive list of standard parameters and their default values.
Usage | Parameter | Default |
---|---|---|
Changing an elastic agent home directory (applicationHome, buildWorkingDirectory, localHomeDirectory, sharedHomeDirectory) | bamboo.home | $USER_HOME/bamboo-agent-home |
Adjusting the initial Java heap size of the elastic agent | wrapper.java.initmemory | 256MB |
Adjusting the maximum Java heap size of the elastic agent | wrapper.java.maxmemory | 256MB |
Changing the default action for the elastic agent supervisor when the JVM fails to respond to its ping requests | wrapper.ping.timeout.action | RESTART |
Changing the interval at which the JVM is pinged | wrapper.ping.timeout | 30s |
Instance startup script
To customize the JVM arguments for your elastic agents, you must edit the elastic image they're using and add the following startup script:
- Go to Bamboo administration >> Overview >> Elastic Bamboo >> Image configurations page.
- From there, edit the desired elastic image.
Locate the Instance startup script field and use one of the following examples to modify your agent's JVM arguments:
Linuxsudo su -c "echo \"export WRAPPER_PROPERTIES='\"-Dwrapper.java.additional.4=-Dbamboo.home=/home/bamboo/new-home\"'\" >> /etc/profile.d/bamboo.sh"
Windows (Powershell)powershell.exe -Command "[System.Environment]::SetEnvironmentVariable(\"WRAPPER_PROPERTIES\", '\" -Dwrapper.java.additional.4=-Dbamboo.home=C:\Bamboo\new-home \"', 'Machine')"
- Save the elastic image configuration and start a new elastic agent.
- The changes won't affect elastic agents that are running; they will only affect new ones.
- The changes won't affect elastic agents that are running; they will only affect new ones.
JVM parameters are all prefixed by -D,
so bamboo.home
would be added to the Java command as -Dbamboo.home
With the wrapper properties as -Dbamboo.home
we can set a new path for the Bamboo home directory. The applicationHome, buildWorkingDirectory, localHomeDirectory, and sharedHomeDirectory are all set as new Bamboo home paths. However, the currentDirectory will still be pointing to the home dir of the Bamboo user. As a workaround, if we set the environment variable for BAMBOO_HOME, the currentDirectory changes.
Additional ElasticAgent options you can set manually after the startup: