Elastic Agent Instance startup script samples

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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

Bamboo elastic agents allow you to configure an instance start-up script at Bamboo Administration > Overview > Image Configurations > Edit. This script is executed when the EC2 instance starts. Below are some sample instance-startup scripts to achieve different things which you may find useful as a reference point.

Bamboo Global variables are not accessible from the instance startup script text field. Variables are only available to the Elastic agent after it is online.

If you have a specific need for a Global variable in an elastic agent, you can use plan variables along with a script task in a Job.

Solution

Adding JAVA options

Adding to the instance startup script through the UI Bamboo Administration > Overview > Image Configurations > Edit

For Linux Image

1 sed -i 's@.*MARKER.*@sed -i "s/-Xmx256m/-Xmx256m -Datlassian.org.osgi.framework.bootdelegation=javax.servlet,javax.servlet.*,sun.*,com.sun.*,org.w3c.dom.*,org.apache.xerces.*/" $startupScript@' /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent

For Window Image

1 sed -i 's@.*MARKER.*@sed -i "s/-Xmx512m/-Xmx1024m -Datlassian.org.osgi.framework.bootdelegation=javax.servlet,javax.servlet.*,sun.*,com.sun.*,org.w3c.dom.*,org.apache.xerces.*/" $startupScript@' C:\opt\bamboo-elastic-agent\bin\bamboo-elastic-agent.bat

Add it directly to the instance startup script using:

echo export MY_VARIABLE=value >> /etc/environment

Linux

1 echo export _JAVA_OPTIONS=\"-Datlassian.org.osgi.framework.bootdelegation=javax.servlet,javax.servlet.\*,sun.\*,com.sun.\*,org.w3c.dom.\*,org.apache.xerces.\*\" >> /etc/environment

Windows

1 setx _JAVA_OPTIONS "-Datlassian.org.osgi.framework.bootdelegation=javax.servlet,javax.servlet.*,sun.*,com.sun.*,org.w3c.dom.*,org.apache.xerces.*"

Appending the path variable

The variable can also be changed before the agent is started by adding the following line to the machine star tup script:

Linux

1 echo export PATH=$PATH:/new/path >> /etc/environment

Windows

1 set PATH=%PATH%;C:\new\path

Changing MAVEN_HOME definition

The MAVEN_HOME can be changed with the following sed command:

Linux

1 sed -i 's@(export MAVEN_HOME=).*@\1/opt/maven-3.5@g' /opt/profile.d/bamboo.sh

Windows

1 sed -i 's@(export MAVEN_HOME=).*@\1/opt/maven-3.5@g' C:\opt\bamboo-elastic-agent\etc\profile.sh
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.