Elastic Agent Instance startup script samples

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

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.

tip/resting Created with Sketch.

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

Click here to expand...

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

For Linux Image

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

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

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

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

Click here to expand...

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

Linux

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

Windows


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



Changing MAVEN_HOME definition

Click here to expand...

The MAVEN_HOME can be changed with the following sed command:

Linux

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

Windows

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

Last modified on May 18, 2022

Was this helpful?

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