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

Still need help?

The Atlassian Community is here for you.

Ask the community

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 

      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 

      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

Last modified on Oct 30, 2019

Was this helpful?

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