How to change the build working directory on Bamboo Stock Image elastic agents

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

Problem

Storage limits on some elastic agent instances might require that the build directory of the elastic agent be relocated.

Workaround

You can solve this problem by adding a startup script to your image in Bamboo that will mount an external storage location to a local folder and update the agent configuration.

  1. In Bamboo server, go to Admin >> Elastic Instances >> Image Configurations

  2. Select the Stock image you want to customize and click Edit

  3. Go to Instance startup script field and add the following script:

    1. Linux Stock image

      1 2 3 4 5 6 7 8 9 mkdir /b chown bamboo:bamboo -R /b mkdir -p /mnt/bamboo-ebs/bamboo-agent/ cp /opt/bamboo-elastic-agent/ebs-resources/bamboo-agent.cfg.xml /mnt/bamboo-ebs/bamboo-agent/ chown bamboo:bamboo -R /mnt/bamboo-ebs sed -i 's:<buildWorkingDirectory>.*</buildWorkingDirectory>:<buildWorkingDirectory>/b</buildWorkingDirectory>:g' /mnt/bamboo-ebs/bamboo-agent/bamboo-agent.cfg.xml su - bamboo -c "/opt/bamboo-elastic-agent/ebs-resources/customiseInstance.sh"
    2. Windows Stock image

      1 2 3 4 mkdir C:\b icacls "C:\b" /grant Bamboo:(OI)(CI)F /T sed -i "s/<buildWorkingDirectory>.*</<buildWorkingDirectory>c:\\\b</" C:\Users\Bamboo\bamboo-agent-home\bamboo-agent.cfg.template.xml
  4. Start your elastic instance

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.