How to customize Java Virtual Machine (JVM) and wrapper settings for your Bamboo elastic agents

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.

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.

UsageParameterDefault
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 agentwrapper.java.initmemory256MB
Adjusting the maximum Java heap size of the elastic agentwrapper.java.maxmemory256MB
Changing the default action for the elastic agent supervisor when the JVM fails to respond to its ping requestswrapper.ping.timeout.actionRESTART
Changing the interval at which the JVM is pingedwrapper.ping.timeout30s

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:

  1. Go to Bamboo administration >> Overview >> Elastic Bamboo >> Image configurations page.
  2. From there, edit the desired elastic image.
  3. Locate the Instance startup script field and use one of the following examples to modify your agent's JVM arguments:

    Linux
    sudo 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')"
  4. Save the elastic image configuration and start a new elastic agent.
    1. 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.

Last modified on Oct 2, 2023

Was this helpful?

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